diff --git a/src/main/java/cpw/mods/fml/relauncher/ServerLaunchWrapper.java b/src/main/java/cpw/mods/fml/relauncher/ServerLaunchWrapper.java
index fe709eb..ef86365 100644
--- a/src/main/java/cpw/mods/fml/relauncher/ServerLaunchWrapper.java
+++ b/src/main/java/cpw/mods/fml/relauncher/ServerLaunchWrapper.java
@@ -1,57 +1,57 @@
-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)
- {
- boolean useUMConsole = Boolean.parseBoolean(System.getProperty("org.ultramine.server.umconsole"));
- System.out.println((useUMConsole ? "\u00A7e" : "") + "================[ Starting UltraMine server ]================");
- System.setProperty("Log4jContextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"); //always async logging
-
- 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);
- }
- }
-
+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)
+ {
+ boolean useUMConsole = Boolean.parseBoolean(System.getProperty("org.ultramine.server.umconsole"));
+ System.out.println((useUMConsole ? "\u00A7e" : "") + "================[ Starting UltraMine server ]================");
+ System.setProperty("Log4jContextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"); //always async logging
+
+ 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/net/minecraft/command/CommandBase.java b/src/main/java/net/minecraft/command/CommandBase.java
index c81a422..e6a6ce7 100644
--- a/src/main/java/net/minecraft/command/CommandBase.java
+++ b/src/main/java/net/minecraft/command/CommandBase.java
@@ -1,497 +1,497 @@
-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;
-import net.minecraft.world.World;
-
-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, -World.MAX_BLOCK_COORD, World.MAX_BLOCK_COORD);
- }
-
- 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);
- }
+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;
+import net.minecraft.world.World;
+
+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, -World.MAX_BLOCK_COORD, World.MAX_BLOCK_COORD);
+ }
+
+ 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/entity/player/EntityPlayerMP.java b/src/main/java/net/minecraft/entity/player/EntityPlayerMP.java
index 1236103..855d3d5 100644
--- a/src/main/java/net/minecraft/entity/player/EntityPlayerMP.java
+++ b/src/main/java/net/minecraft/entity/player/EntityPlayerMP.java
@@ -1,996 +1,996 @@
-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 org.ultramine.server.chunk.ChunkSendManager;
-
-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));
- }
-
- getChunkMgr().update();
-
- 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() && getServerForPlayer().getConfig().settings.pvp && "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 !getServerForPlayer().getConfig().settings.pvp ? 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 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();
-
- this.renderDistance = MathHelper.clamp_int(i, 3, 15);
-
- 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;
- }
-
- /* ===================================== ULTRAMINE START =====================================*/
-
- private final ChunkSendManager chunkMgr = new ChunkSendManager(this);
-
- @Override
- public boolean isEntityPlayerMP()
- {
- return true;
- }
-
- public ChunkSendManager getChunkMgr()
- {
- return chunkMgr;
- }
-
- public int getRenderDistance()
- {
- return renderDistance;
- }
-
- /**
- * Переносит игрока в другой мир без использования порталов. Обратите
- * внимение: сначала нужно установить координаты назначения
- * setPlayerLocation()
, а потом уже переносить в другой мир.
- */
- public void transferToDimension(int dim)
- {
- this.mcServer.getConfigurationManager().transferPlayerToDimension(this, dim, null);
- this.lastExperience = -1;
- this.lastHealth = -1.0F;
- this.lastFoodLevel = -1;
- }
+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 org.ultramine.server.chunk.ChunkSendManager;
+
+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));
+ }
+
+ getChunkMgr().update();
+
+ 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() && getServerForPlayer().getConfig().settings.pvp && "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 !getServerForPlayer().getConfig().settings.pvp ? 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 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();
+
+ this.renderDistance = MathHelper.clamp_int(i, 3, 15);
+
+ 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;
+ }
+
+ /* ===================================== ULTRAMINE START =====================================*/
+
+ private final ChunkSendManager chunkMgr = new ChunkSendManager(this);
+
+ @Override
+ public boolean isEntityPlayerMP()
+ {
+ return true;
+ }
+
+ public ChunkSendManager getChunkMgr()
+ {
+ return chunkMgr;
+ }
+
+ public int getRenderDistance()
+ {
+ return renderDistance;
+ }
+
+ /**
+ * Переносит игрока в другой мир без использования порталов. Обратите
+ * внимение: сначала нужно установить координаты назначения
+ * setPlayerLocation()
, а потом уже переносить в другой мир.
+ */
+ public void transferToDimension(int dim)
+ {
+ this.mcServer.getConfigurationManager().transferPlayerToDimension(this, dim, null);
+ this.lastExperience = -1;
+ this.lastHealth = -1.0F;
+ this.lastFoodLevel = -1;
+ }
}
\ 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
index ec301ae..604d152 100644
--- a/src/main/java/net/minecraft/network/NetHandlerPlayServer.java
+++ b/src/main/java/net/minecraft/network/NetHandlerPlayServer.java
@@ -1,1289 +1,1289 @@
-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.MathHelper;
-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 cpw.mods.fml.common.eventhandler.Event;
-import net.minecraftforge.event.ForgeEventFactory;
-import net.minecraftforge.event.entity.player.PlayerInteractEvent;
-
-import org.ultramine.permission.MinecraftPermissions;
-import org.ultramine.server.PermissionHandler;
-
-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)
- {
- if(!playerEntity.worldObj.blockExists(MathHelper.floor_double(playerEntity.posX), 64, MathHelper.floor_double(playerEntity.posZ)))
- return;
-
- 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 >= playerEntity.getServerForPlayer().getConfig().settings.maxBuildHeight)
- {
- 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();
-
- int buildlimit = playerEntity.getServerForPlayer().getConfig().settings.maxBuildHeight;
-
- if (p_147346_1_.func_149568_f() == 255)
- {
- if (itemstack == null)
- {
- return;
- }
-
+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.MathHelper;
+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 cpw.mods.fml.common.eventhandler.Event;
+import net.minecraftforge.event.ForgeEventFactory;
+import net.minecraftforge.event.entity.player.PlayerInteractEvent;
+
+import org.ultramine.permission.MinecraftPermissions;
+import org.ultramine.server.PermissionHandler;
+
+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)
+ {
+ if(!playerEntity.worldObj.blockExists(MathHelper.floor_double(playerEntity.posX), 64, MathHelper.floor_double(playerEntity.posZ)))
+ return;
+
+ 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 >= playerEntity.getServerForPlayer().getConfig().settings.maxBuildHeight)
+ {
+ 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();
+
+ int buildlimit = playerEntity.getServerForPlayer().getConfig().settings.maxBuildHeight;
+
+ 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, worldserver);
- if (event.useItem != Event.Result.DENY)
- {
- this.playerEntity.theItemInWorldManager.tryUseItem(this.playerEntity, worldserver, itemstack);
- }
- }
- else if (p_147346_1_.func_149571_d() >= buildlimit - 1 && (p_147346_1_.func_149568_f() == 1 || p_147346_1_.func_149571_d() >= buildlimit))
- {
- ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("build.tooHigh", new Object[] {Integer.valueOf(buildlimit)});
- 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 && !PermissionHandler.getInstance().has(playerEntity, MinecraftPermissions.ALLOW_SPAM))
- {
- 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)
- {
- ;
- }
- }
- }
+ if (event.useItem != Event.Result.DENY)
+ {
+ this.playerEntity.theItemInWorldManager.tryUseItem(this.playerEntity, worldserver, itemstack);
+ }
+ }
+ else if (p_147346_1_.func_149571_d() >= buildlimit - 1 && (p_147346_1_.func_149568_f() == 1 || p_147346_1_.func_149571_d() >= buildlimit))
+ {
+ ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("build.tooHigh", new Object[] {Integer.valueOf(buildlimit)});
+ 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 && !PermissionHandler.getInstance().has(playerEntity, MinecraftPermissions.ALLOW_SPAM))
+ {
+ 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)
+ {
+ ;
+ }
+ }
+ }
}
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java b/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java
index 1779d8f..4279912 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java
@@ -1,188 +1,188 @@
-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.management.ServerConfigurationManager;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.ultramine.permission.MinecraftPermissions;
-import org.ultramine.server.ConfigurationHandler;
-import org.ultramine.server.PermissionHandler;
-
-@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 = ConfigurationHandler.getWorldsConfig().global.chunkLoading.viewDistance;
- this.maxPlayers = ConfigurationHandler.getServerConfig().vanilla.maxPlayers;
- this.setWhiteListEnabled(ConfigurationHandler.getServerConfig().vanilla.whiteList);
-
- if (!par1DedicatedServer.isSinglePlayer())
- {
- this.getBannedPlayers().setListActive(true);
- this.getBannedIPs().setListActive(true);
- }
-
- this.getBannedPlayers().loadBanList();
- this.getBannedPlayers().saveToFileWithHeader();
- this.getBannedIPs().loadBanList();
- this.getBannedIPs().saveToFileWithHeader();
- this.readWhiteList();
-
- if (!this.whiteList.exists())
- {
- this.saveWhiteList();
- }
- }
-
- public void setWhiteListEnabled(boolean par1)
- {
- super.setWhiteListEnabled(par1);
- ConfigurationHandler.getServerConfig().vanilla.whiteList = par1;
- this.getServerInstance().saveProperties();
- }
-
- public void addOp(String par1Str)
- {
- super.addOp(par1Str);
- PermissionHandler.getInstance().save();
- }
-
- public void removeOp(String par1Str)
- {
- super.removeOp(par1Str);
- PermissionHandler.getInstance().save();
- }
-
- 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.getWhiteListedPlayers().contains(par1Str)
- || PermissionHandler.getInstance().hasGlobally(par1Str, MinecraftPermissions.IGNORE_WHITE_LIST);
- }
-
- public DedicatedServer getServerInstance()
- {
- return (DedicatedServer)super.getServerInstance();
- }
+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.management.ServerConfigurationManager;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.ultramine.permission.MinecraftPermissions;
+import org.ultramine.server.ConfigurationHandler;
+import org.ultramine.server.PermissionHandler;
+
+@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 = ConfigurationHandler.getWorldsConfig().global.chunkLoading.viewDistance;
+ this.maxPlayers = ConfigurationHandler.getServerConfig().vanilla.maxPlayers;
+ this.setWhiteListEnabled(ConfigurationHandler.getServerConfig().vanilla.whiteList);
+
+ if (!par1DedicatedServer.isSinglePlayer())
+ {
+ this.getBannedPlayers().setListActive(true);
+ this.getBannedIPs().setListActive(true);
+ }
+
+ this.getBannedPlayers().loadBanList();
+ this.getBannedPlayers().saveToFileWithHeader();
+ this.getBannedIPs().loadBanList();
+ this.getBannedIPs().saveToFileWithHeader();
+ this.readWhiteList();
+
+ if (!this.whiteList.exists())
+ {
+ this.saveWhiteList();
+ }
+ }
+
+ public void setWhiteListEnabled(boolean par1)
+ {
+ super.setWhiteListEnabled(par1);
+ ConfigurationHandler.getServerConfig().vanilla.whiteList = par1;
+ this.getServerInstance().saveProperties();
+ }
+
+ public void addOp(String par1Str)
+ {
+ super.addOp(par1Str);
+ PermissionHandler.getInstance().save();
+ }
+
+ public void removeOp(String par1Str)
+ {
+ super.removeOp(par1Str);
+ PermissionHandler.getInstance().save();
+ }
+
+ 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.getWhiteListedPlayers().contains(par1Str)
+ || PermissionHandler.getInstance().hasGlobally(par1Str, MinecraftPermissions.IGNORE_WHITE_LIST);
+ }
+
+ 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
index ac81398..fb3e360 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -1,502 +1,502 @@
-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.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.WorldServer;
-import net.minecraft.world.WorldSettings;
-import net.minecraft.world.WorldType;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.ultramine.permission.MinecraftPermissions;
-import org.ultramine.permission.PermissionRepository;
-import org.ultramine.permission.internal.ServerPermissionManager;
-import org.ultramine.server.ConfigurationHandler;
-import org.ultramine.server.PermissionHandler;
-import org.ultramine.server.UltramineServerConfig.VanillaConfig;
-import org.ultramine.server.WorldsConfig.WorldConfig;
-import org.ultramine.server.util.BasicTypeParser;
-
-@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 VanillaConfig 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");
- settings = ConfigurationHandler.getServerConfig().vanilla;
- WorldConfig globalWConf = ConfigurationHandler.getWorldsConfig().global;
-
- if (this.isSinglePlayer())
- {
- this.setHostname("127.0.0.1");
- }
- else
- {
- this.setOnlineMode(settings.onlineMode);
- this.setHostname(settings.serverIp);
- }
-
- this.setCanSpawnAnimals(globalWConf.mobSpawn.spawnAnimals);
- this.setCanSpawnNPCs(globalWConf.mobSpawn.spawnNPCs);
- this.setAllowPvp(globalWConf.settings.pvp);
- this.setAllowFlight(settings.allowFlight);
- this.func_155759_m(settings.resourcePack);
- this.setMOTD(settings.motd);
- this.setForceGamemode(settings.forceGamemode);
- this.func_143006_e(settings.playerIdleTimeout);
-
- this.canSpawnStructures = globalWConf.generation.generateStructures;
- int i = settings.gamemode;
- 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(settings.serverPort);
- }
-
- 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("world");
- }
-
- String s = globalWConf.generation.seed;
- String s1 = globalWConf.generation.levelType;
- String s2 = globalWConf.generation.generatorSettings;
- 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(globalWConf.settings.maxBuildHeight);
- this.setBuildLimit((this.getBuildLimit() + 8) / 16 * 16);
- this.setBuildLimit(MathHelper.clamp_int(this.getBuildLimit(), 64, 256));
- globalWConf.settings.maxBuildHeight = this.getBuildLimit();
- this.setPermissionManager(new ServerPermissionManager(ConfigurationHandler.getSettingDir(), new PermissionRepository())); // ultramine
- 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 (settings.enableQuery)
- {
- field_155771_h.info("Starting GS4 status listener");
- this.theRConThreadQuery = new RConThreadQuery(this);
- this.theRConThreadQuery.startThread();
- }
-
- if (settings.enableRcon)
- {
- 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 BasicTypeParser.parseDifficulty(ConfigurationHandler.getWorldsConfig().global.settings.difficulty);
- }
-
- public boolean isHardcore()
- {
- return settings.hardcore;
- }
-
- 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.getMultiWorld().getWorldByID(-1) != null;
- }
-
- public boolean allowSpawnMonsters()
- {
- return ConfigurationHandler.getWorldsConfig().global.mobSpawn.spawnMonsters;
- }
-
- 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 settings.snooperEnabled;
- }
-
- 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)
- {
- logInfo("Attempted to get server config unresolved integer parameter " + par1Str);
- return settings.unresolved.containsKey(par1Str) ? (Integer)settings.unresolved.get(par1Str) : par2;
- }
-
- public String getStringProperty(String par1Str, String par2Str)
- {
- logInfo("Attempted to get server config unresolved string parameter " + par1Str);
- return settings.unresolved.containsKey(par1Str) ? (String)settings.unresolved.get(par1Str) : par2Str;
- }
-
- public boolean getBooleanProperty(String par1Str, boolean par2)
- {
- logInfo("Attempted to get server config unresolved boolean parameter " + par1Str);
- return settings.unresolved.containsKey(par1Str) ? (Boolean)settings.unresolved.get(par1Str) : par2;
- }
-
- public void setProperty(String par1Str, Object par2Obj)
- {
- logInfo("Attempted to set server config unresolved parameter " + par1Str);
- settings.unresolved.put(par1Str, par2Obj);
- }
-
- public void saveProperties()
- {
- ConfigurationHandler.saveServerConfig();
- }
-
- public String getSettingsFilename()
- {
- return "server.yml";
- }
-
- 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 settings.enableCommandBlock;
- }
-
- public int getSpawnProtectionSize()
- {
- return 0;
- }
-
- 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 (PermissionHandler.getInstance().has(par5EntityPlayer, MinecraftPermissions.IGNORE_SPAWN_PROTECTION))
- {
- 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 4;
- }
-
- public void func_143006_e(int par1)
- {
- super.func_143006_e(par1);
- settings.playerIdleTimeout = par1;
- this.saveProperties();
- }
-
- public boolean func_147136_ar()
- {
- return settings.announcePlayerAchievements;
- }
-
- /* ======================================== ULTRAMINE START =====================================*/
-
- protected void loadAllWorlds(String par1Str, String par2Str, long par3, WorldType par5WorldType, String par6Str)
- {
- convertMapIfNeeded(par1Str);
- setUserMessage("menu.loadingLevel");
-
- getMultiWorld().handleServerWorldsInit();
-
- getConfigurationManager().setPlayerManager(new WorldServer[]{ getMultiWorld().getWorldByID(0) });
- initialWorldChunkLoad();
- }
-
- protected File getDataDirectory()
- {
- return ConfigurationHandler.getSettingDir();
- }
+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.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.WorldServer;
+import net.minecraft.world.WorldSettings;
+import net.minecraft.world.WorldType;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.ultramine.permission.MinecraftPermissions;
+import org.ultramine.permission.PermissionRepository;
+import org.ultramine.permission.internal.ServerPermissionManager;
+import org.ultramine.server.ConfigurationHandler;
+import org.ultramine.server.PermissionHandler;
+import org.ultramine.server.UltramineServerConfig.VanillaConfig;
+import org.ultramine.server.WorldsConfig.WorldConfig;
+import org.ultramine.server.util.BasicTypeParser;
+
+@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 VanillaConfig 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");
+ settings = ConfigurationHandler.getServerConfig().vanilla;
+ WorldConfig globalWConf = ConfigurationHandler.getWorldsConfig().global;
+
+ if (this.isSinglePlayer())
+ {
+ this.setHostname("127.0.0.1");
+ }
+ else
+ {
+ this.setOnlineMode(settings.onlineMode);
+ this.setHostname(settings.serverIp);
+ }
+
+ this.setCanSpawnAnimals(globalWConf.mobSpawn.spawnAnimals);
+ this.setCanSpawnNPCs(globalWConf.mobSpawn.spawnNPCs);
+ this.setAllowPvp(globalWConf.settings.pvp);
+ this.setAllowFlight(settings.allowFlight);
+ this.func_155759_m(settings.resourcePack);
+ this.setMOTD(settings.motd);
+ this.setForceGamemode(settings.forceGamemode);
+ this.func_143006_e(settings.playerIdleTimeout);
+
+ this.canSpawnStructures = globalWConf.generation.generateStructures;
+ int i = settings.gamemode;
+ 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(settings.serverPort);
+ }
+
+ 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("world");
+ }
+
+ String s = globalWConf.generation.seed;
+ String s1 = globalWConf.generation.levelType;
+ String s2 = globalWConf.generation.generatorSettings;
+ 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(globalWConf.settings.maxBuildHeight);
+ this.setBuildLimit((this.getBuildLimit() + 8) / 16 * 16);
+ this.setBuildLimit(MathHelper.clamp_int(this.getBuildLimit(), 64, 256));
+ globalWConf.settings.maxBuildHeight = this.getBuildLimit();
+ this.setPermissionManager(new ServerPermissionManager(ConfigurationHandler.getSettingDir(), new PermissionRepository())); // ultramine
+ 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 (settings.enableQuery)
+ {
+ field_155771_h.info("Starting GS4 status listener");
+ this.theRConThreadQuery = new RConThreadQuery(this);
+ this.theRConThreadQuery.startThread();
+ }
+
+ if (settings.enableRcon)
+ {
+ 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 BasicTypeParser.parseDifficulty(ConfigurationHandler.getWorldsConfig().global.settings.difficulty);
+ }
+
+ public boolean isHardcore()
+ {
+ return settings.hardcore;
+ }
+
+ 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.getMultiWorld().getWorldByID(-1) != null;
+ }
+
+ public boolean allowSpawnMonsters()
+ {
+ return ConfigurationHandler.getWorldsConfig().global.mobSpawn.spawnMonsters;
+ }
+
+ 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 settings.snooperEnabled;
+ }
+
+ 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)
+ {
+ logInfo("Attempted to get server config unresolved integer parameter " + par1Str);
+ return settings.unresolved.containsKey(par1Str) ? (Integer)settings.unresolved.get(par1Str) : par2;
+ }
+
+ public String getStringProperty(String par1Str, String par2Str)
+ {
+ logInfo("Attempted to get server config unresolved string parameter " + par1Str);
+ return settings.unresolved.containsKey(par1Str) ? (String)settings.unresolved.get(par1Str) : par2Str;
+ }
+
+ public boolean getBooleanProperty(String par1Str, boolean par2)
+ {
+ logInfo("Attempted to get server config unresolved boolean parameter " + par1Str);
+ return settings.unresolved.containsKey(par1Str) ? (Boolean)settings.unresolved.get(par1Str) : par2;
+ }
+
+ public void setProperty(String par1Str, Object par2Obj)
+ {
+ logInfo("Attempted to set server config unresolved parameter " + par1Str);
+ settings.unresolved.put(par1Str, par2Obj);
+ }
+
+ public void saveProperties()
+ {
+ ConfigurationHandler.saveServerConfig();
+ }
+
+ public String getSettingsFilename()
+ {
+ return "server.yml";
+ }
+
+ 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 settings.enableCommandBlock;
+ }
+
+ public int getSpawnProtectionSize()
+ {
+ return 0;
+ }
+
+ 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 (PermissionHandler.getInstance().has(par5EntityPlayer, MinecraftPermissions.IGNORE_SPAWN_PROTECTION))
+ {
+ 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 4;
+ }
+
+ public void func_143006_e(int par1)
+ {
+ super.func_143006_e(par1);
+ settings.playerIdleTimeout = par1;
+ this.saveProperties();
+ }
+
+ public boolean func_147136_ar()
+ {
+ return settings.announcePlayerAchievements;
+ }
+
+ /* ======================================== ULTRAMINE START =====================================*/
+
+ protected void loadAllWorlds(String par1Str, String par2Str, long par3, WorldType par5WorldType, String par6Str)
+ {
+ convertMapIfNeeded(par1Str);
+ setUserMessage("menu.loadingLevel");
+
+ getMultiWorld().handleServerWorldsInit();
+
+ getConfigurationManager().setPlayerManager(new WorldServer[]{ getMultiWorld().getWorldByID(0) });
+ initialWorldChunkLoad();
+ }
+
+ protected File getDataDirectory()
+ {
+ return ConfigurationHandler.getSettingDir();
+ }
}
\ 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
index 3e1c59b..c418b13 100644
--- a/src/main/java/net/minecraft/server/integrated/IntegratedServer.java
+++ b/src/main/java/net/minecraft/server/integrated/IntegratedServer.java
@@ -1,274 +1,274 @@
-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;
-import org.ultramine.permission.PermissionRepository;
-import org.ultramine.permission.internal.ClientPermissionManager;
-
-@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.mc = par1Minecraft;
- this.setConfigurationManager(new IntegratedPlayerList(this));
- 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));
- }
-
- getMultiWorld().handleClientWorldsInit();
-
- 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());
- this.setPermissionManager(new ClientPermissionManager(getServerOwner(), new PermissionRepository())); // ultramine
- 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;
- }
+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;
+import org.ultramine.permission.PermissionRepository;
+import org.ultramine.permission.internal.ClientPermissionManager;
+
+@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.mc = par1Minecraft;
+ this.setConfigurationManager(new IntegratedPlayerList(this));
+ 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));
+ }
+
+ getMultiWorld().handleClientWorldsInit();
+
+ 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());
+ this.setPermissionManager(new ClientPermissionManager(getServerOwner(), new PermissionRepository())); // ultramine
+ 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/PlayerManager.java b/src/main/java/net/minecraft/server/management/PlayerManager.java
index 5a68b1d..8c0002e 100644
--- a/src/main/java/net/minecraft/server/management/PlayerManager.java
+++ b/src/main/java/net/minecraft/server/management/PlayerManager.java
@@ -1,415 +1,415 @@
-package net.minecraft.server.management;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-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();
- }
- }
- }
-
- public 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)
- {
- par1EntityPlayerMP.getChunkMgr().addTo(this);
- players.add(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)
- {
- par1EntityPlayerMP.getChunkMgr().removeFrom(this);
- 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)
- {
- par1EntityPlayerMP.getChunkMgr().updatePlayerPertinentChunks();
- }
-
- 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;
- }
-
- public 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);
-// getWorldServer().theChunkProviderServer.loadAsync(par2, par3, this.loadedRunnable);
- }
-
- 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);
- }
- }
-
- 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(S21PacketChunkData.makeForUnload(chunk));
- }
-
- 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.unbindChunk(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);
- }
- }
- }
- }
+package net.minecraft.server.management;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+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();
+ }
+ }
+ }
+
+ public 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)
+ {
+ par1EntityPlayerMP.getChunkMgr().addTo(this);
+ players.add(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)
+ {
+ par1EntityPlayerMP.getChunkMgr().removeFrom(this);
+ 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)
+ {
+ par1EntityPlayerMP.getChunkMgr().updatePlayerPertinentChunks();
+ }
+
+ 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;
+ }
+
+ public 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);
+// getWorldServer().theChunkProviderServer.loadAsync(par2, par3, this.loadedRunnable);
+ }
+
+ 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);
+ }
+ }
+
+ 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(S21PacketChunkData.makeForUnload(chunk));
+ }
+
+ 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.unbindChunk(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/util/ChatComponentStyle.java b/src/main/java/net/minecraft/util/ChatComponentStyle.java
index 73d824b..0f58861 100644
--- a/src/main/java/net/minecraft/util/ChatComponentStyle.java
+++ b/src/main/java/net/minecraft/util/ChatComponentStyle.java
@@ -1,158 +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 + '}';
- }
+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/ChatStyle.java b/src/main/java/net/minecraft/util/ChatStyle.java
index 69d8505..8d8c103 100644
--- a/src/main/java/net/minecraft/util/ChatStyle.java
+++ b/src/main/java/net/minecraft/util/ChatStyle.java
@@ -1,508 +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);
- }
- }
+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/EnumChatFormatting.java b/src/main/java/net/minecraft/util/EnumChatFormatting.java
index 4f75a42..f3cb355 100644
--- a/src/main/java/net/minecraft/util/EnumChatFormatting.java
+++ b/src/main/java/net/minecraft/util/EnumChatFormatting.java
@@ -1,128 +1,128 @@
-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);
- }
- }
-
- public static EnumChatFormatting getByColorCode(char code)
- {
- return (EnumChatFormatting)formattingCodeMapping.get(code);
- }
+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);
+ }
+ }
+
+ public static EnumChatFormatting getByColorCode(char code)
+ {
+ return (EnumChatFormatting)formattingCodeMapping.get(code);
+ }
}
\ 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
index 5b1d405..f15d971 100644
--- a/src/main/java/net/minecraft/util/IChatComponent.java
+++ b/src/main/java/net/minecraft/util/IChatComponent.java
@@ -1,261 +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();
- }
- }
+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/world/SpawnerAnimals.java b/src/main/java/net/minecraft/world/SpawnerAnimals.java
index d26b751..56ae690 100644
--- a/src/main/java/net/minecraft/world/SpawnerAnimals.java
+++ b/src/main/java/net/minecraft/world/SpawnerAnimals.java
@@ -1,295 +1,295 @@
-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 org.ultramine.server.ConfigurationHandler;
-
-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);
- int b0 = par1WorldServer.getConfig().chunkLoading.chunkUpdateRadius;
-
- for (int l = -b0; l <= b0; ++l)
- {
- for (int i1 = -b0; i1 <= b0; ++i1)
- {
- int cx = l + j;
- int cz = i1 + k;
-
- if(par1WorldServer.chunkRoundExists(cx, cz, 1))
- {
- boolean flag3 = l == -b0 || l == b0 || i1 == -b0 || i1 == b0;
- ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(cx, cz);
-
- 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(!par1World.blockExists(par2, par3, par4)) return false;
-
- 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);
- }
- }
- }
- }
- }
- }
+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 org.ultramine.server.ConfigurationHandler;
+
+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);
+ int b0 = par1WorldServer.getConfig().chunkLoading.chunkUpdateRadius;
+
+ for (int l = -b0; l <= b0; ++l)
+ {
+ for (int i1 = -b0; i1 <= b0; ++i1)
+ {
+ int cx = l + j;
+ int cz = i1 + k;
+
+ if(par1WorldServer.chunkRoundExists(cx, cz, 1))
+ {
+ boolean flag3 = l == -b0 || l == b0 || i1 == -b0 || i1 == b0;
+ ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(cx, cz);
+
+ 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(!par1World.blockExists(par2, par3, par4)) return false;
+
+ 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/World.java b/src/main/java/net/minecraft/world/World.java
index de35ada..a296793 100644
--- a/src/main/java/net/minecraft/world/World.java
+++ b/src/main/java/net/minecraft/world/World.java
@@ -1,4017 +1,4017 @@
-package net.minecraft.world;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import gnu.trove.map.TIntByteMap;
-import gnu.trove.map.hash.TIntByteHashMap;
-
-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 org.ultramine.server.ConfigurationHandler;
-import org.ultramine.server.chunk.ChunkHash;
-
-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.entity.player.EntityPlayerMP;
-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 TIntByteMap activeChunkSet = new TIntByteHashMap(512, 0.75F, 0, Byte.MAX_VALUE);//XXX
- 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_ >= -MAX_BLOCK_COORD && p_147439_3_ >= -MAX_BLOCK_COORD && p_147439_1_ < MAX_BLOCK_COORD && p_147439_3_ < MAX_BLOCK_COORD && 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;
- }
- }
-
- public 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_ >= -MAX_BLOCK_COORD && p_147465_3_ >= -MAX_BLOCK_COORD && p_147465_1_ < MAX_BLOCK_COORD && p_147465_3_ < MAX_BLOCK_COORD)
- {
- 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 >= -MAX_BLOCK_COORD && par3 >= -MAX_BLOCK_COORD && par1 < MAX_BLOCK_COORD && par3 < MAX_BLOCK_COORD)
- {
- 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 >= -MAX_BLOCK_COORD && par3 >= -MAX_BLOCK_COORD && par1 < MAX_BLOCK_COORD && par3 < MAX_BLOCK_COORD)
- {
- 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 >= -MAX_BLOCK_COORD && par3 >= -MAX_BLOCK_COORD && par1 < MAX_BLOCK_COORD && par3 < MAX_BLOCK_COORD)
- {
- 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 >= -MAX_BLOCK_COORD && par2 >= -MAX_BLOCK_COORD && par1 < MAX_BLOCK_COORD && par2 < MAX_BLOCK_COORD)
- {
- 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 >= -MAX_BLOCK_COORD && par2 >= -MAX_BLOCK_COORD && par1 < MAX_BLOCK_COORD && par2 < MAX_BLOCK_COORD)
- {
- 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 >= -MAX_BLOCK_COORD && par4 >= -MAX_BLOCK_COORD && par2 < MAX_BLOCK_COORD && par4 < MAX_BLOCK_COORD)
- {
- 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 >= -MAX_BLOCK_COORD && par4 >= -MAX_BLOCK_COORD && par2 < MAX_BLOCK_COORD && par4 < MAX_BLOCK_COORD)
- {
- 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 >= -MAX_BLOCK_COORD && par4 >= -MAX_BLOCK_COORD && par2 < MAX_BLOCK_COORD && par4 < MAX_BLOCK_COORD)
- {
- 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 >= -MAX_BLOCK_COORD && k1 < MAX_BLOCK_COORD && l1 >= -MAX_BLOCK_COORD && l1 < MAX_BLOCK_COORD)
- {
- 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 >= -MAX_BLOCK_COORD && k1 < MAX_BLOCK_COORD && l1 >= -MAX_BLOCK_COORD && l1 < MAX_BLOCK_COORD)
- {
- 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() && activeChunkSet.containsKey(ChunkHash.chunkToKey(tileentity.xCoord >> 4, tileentity.zCoord >> 4)))
- {
- 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);
- boolean canUpdate = par1Entity.isEntityPlayerMP() || activeChunkSet.containsKey(ChunkHash.chunkToKey(i >> 4, j >> 4));
-
- //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();
- }
- }
- else if(par1Entity.isEntityPlayerMP())
- {
- ((EntityPlayerMP)par1Entity).getChunkMgr().updatePlayerPertinentChunks();
- ((EntityPlayerMP)par1Entity).getChunkMgr().update();
- }
-
- 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_ >= -MAX_BLOCK_COORD && p_147445_3_ >= -MAX_BLOCK_COORD && p_147445_1_ < MAX_BLOCK_COORD && p_147445_3_ < MAX_BLOCK_COORD)
- {
- 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");
- if(isChunkLoaderEnabled())
- for(ChunkCoordIntPair c : getPersistentChunks().keySet()) activeChunkSet.put(ChunkHash.chunkToKey(c.chunkXPos, c.chunkZPos), (byte)100);
- 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);
- int b0 = getChunkUpdateRadius();
-
- for (int l = -b0; l <= b0; ++l)
- {
- for (int i1 = -b0; i1 <= b0; ++i1)
- {
- int cx = l + j;
- int cz = i1 + k;
- if(chunkRoundExists(cx, cz, 1))
- {
- int key = ChunkHash.chunkToKey(cx, cz);
- int priority = Math.max(Math.abs(l), Math.abs(i1));
- //Chunk chunk = this.chunkProvider.provideChunk(cx, cy);
- //if(priority > 1) priority -= Math.min(priority-2, (int)(this.getTotalWorldTime() - chunk.lastActiveOrBindTick)/20);
- activeChunkSet.put(key, (byte)Math.min(priority, activeChunkSet.get(key)));
- }
- }
- }
- }
-
- 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 < -MAX_BLOCK_COORD || z < -MAX_BLOCK_COORD || x >= MAX_BLOCK_COORD || z >= MAX_BLOCK_COORD)
- {
- 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 < -MAX_BLOCK_COORD || z < -MAX_BLOCK_COORD || x >= MAX_BLOCK_COORD || z >= MAX_BLOCK_COORD)
- {
- 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;
- }
-
-
-
- /* ======================================== ULTRAMINE START =====================================*/
-
-
- public static final int MAX_BLOCK_COORD = 500000;//524288;
-
- public Chunk getChunkIfExists(int cx, int cz)
- {
- return getChunkFromChunkCoords(cx, cz);
- }
-
- public Block getBlockIfExists(int x, int y, int z)
- {
- if(blockExists(x, y, z))
- return getBlock(x, y, z);
- return Blocks.air;
- }
-
- public boolean chunkRoundExists(int cx, int cz, int radius)
- {
- for(int x = cx - radius; x <= cx + radius; x++)
- for(int z = cz - radius; z <= cz + radius; z++)
- if(!chunkExists(x, z)) return false;
- return true;
- }
-
- protected boolean isChunkLoaderEnabled()
- {
- return true;
- }
-
- protected int getChunkUpdateRadius()
- {
- return 7;
- }
+package net.minecraft.world;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gnu.trove.map.TIntByteMap;
+import gnu.trove.map.hash.TIntByteHashMap;
+
+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 org.ultramine.server.ConfigurationHandler;
+import org.ultramine.server.chunk.ChunkHash;
+
+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.entity.player.EntityPlayerMP;
+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 TIntByteMap activeChunkSet = new TIntByteHashMap(512, 0.75F, 0, Byte.MAX_VALUE);//XXX
+ 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_ >= -MAX_BLOCK_COORD && p_147439_3_ >= -MAX_BLOCK_COORD && p_147439_1_ < MAX_BLOCK_COORD && p_147439_3_ < MAX_BLOCK_COORD && 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;
+ }
+ }
+
+ public 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_ >= -MAX_BLOCK_COORD && p_147465_3_ >= -MAX_BLOCK_COORD && p_147465_1_ < MAX_BLOCK_COORD && p_147465_3_ < MAX_BLOCK_COORD)
+ {
+ 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 >= -MAX_BLOCK_COORD && par3 >= -MAX_BLOCK_COORD && par1 < MAX_BLOCK_COORD && par3 < MAX_BLOCK_COORD)
+ {
+ 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 >= -MAX_BLOCK_COORD && par3 >= -MAX_BLOCK_COORD && par1 < MAX_BLOCK_COORD && par3 < MAX_BLOCK_COORD)
+ {
+ 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 >= -MAX_BLOCK_COORD && par3 >= -MAX_BLOCK_COORD && par1 < MAX_BLOCK_COORD && par3 < MAX_BLOCK_COORD)
+ {
+ 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 >= -MAX_BLOCK_COORD && par2 >= -MAX_BLOCK_COORD && par1 < MAX_BLOCK_COORD && par2 < MAX_BLOCK_COORD)
+ {
+ 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 >= -MAX_BLOCK_COORD && par2 >= -MAX_BLOCK_COORD && par1 < MAX_BLOCK_COORD && par2 < MAX_BLOCK_COORD)
+ {
+ 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 >= -MAX_BLOCK_COORD && par4 >= -MAX_BLOCK_COORD && par2 < MAX_BLOCK_COORD && par4 < MAX_BLOCK_COORD)
+ {
+ 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 >= -MAX_BLOCK_COORD && par4 >= -MAX_BLOCK_COORD && par2 < MAX_BLOCK_COORD && par4 < MAX_BLOCK_COORD)
+ {
+ 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 >= -MAX_BLOCK_COORD && par4 >= -MAX_BLOCK_COORD && par2 < MAX_BLOCK_COORD && par4 < MAX_BLOCK_COORD)
+ {
+ 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 >= -MAX_BLOCK_COORD && k1 < MAX_BLOCK_COORD && l1 >= -MAX_BLOCK_COORD && l1 < MAX_BLOCK_COORD)
+ {
+ 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 >= -MAX_BLOCK_COORD && k1 < MAX_BLOCK_COORD && l1 >= -MAX_BLOCK_COORD && l1 < MAX_BLOCK_COORD)
+ {
+ 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() && activeChunkSet.containsKey(ChunkHash.chunkToKey(tileentity.xCoord >> 4, tileentity.zCoord >> 4)))
+ {
+ 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);
+ boolean canUpdate = par1Entity.isEntityPlayerMP() || activeChunkSet.containsKey(ChunkHash.chunkToKey(i >> 4, j >> 4));
+
+ //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();
+ }
+ }
+ else if(par1Entity.isEntityPlayerMP())
+ {
+ ((EntityPlayerMP)par1Entity).getChunkMgr().updatePlayerPertinentChunks();
+ ((EntityPlayerMP)par1Entity).getChunkMgr().update();
+ }
+
+ 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_ >= -MAX_BLOCK_COORD && p_147445_3_ >= -MAX_BLOCK_COORD && p_147445_1_ < MAX_BLOCK_COORD && p_147445_3_ < MAX_BLOCK_COORD)
+ {
+ 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");
+ if(isChunkLoaderEnabled())
+ for(ChunkCoordIntPair c : getPersistentChunks().keySet()) activeChunkSet.put(ChunkHash.chunkToKey(c.chunkXPos, c.chunkZPos), (byte)100);
+ 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);
+ int b0 = getChunkUpdateRadius();
+
+ for (int l = -b0; l <= b0; ++l)
+ {
+ for (int i1 = -b0; i1 <= b0; ++i1)
+ {
+ int cx = l + j;
+ int cz = i1 + k;
+ if(chunkRoundExists(cx, cz, 1))
+ {
+ int key = ChunkHash.chunkToKey(cx, cz);
+ int priority = Math.max(Math.abs(l), Math.abs(i1));
+ //Chunk chunk = this.chunkProvider.provideChunk(cx, cy);
+ //if(priority > 1) priority -= Math.min(priority-2, (int)(this.getTotalWorldTime() - chunk.lastActiveOrBindTick)/20);
+ activeChunkSet.put(key, (byte)Math.min(priority, activeChunkSet.get(key)));
+ }
+ }
+ }
+ }
+
+ 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 < -MAX_BLOCK_COORD || z < -MAX_BLOCK_COORD || x >= MAX_BLOCK_COORD || z >= MAX_BLOCK_COORD)
+ {
+ 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 < -MAX_BLOCK_COORD || z < -MAX_BLOCK_COORD || x >= MAX_BLOCK_COORD || z >= MAX_BLOCK_COORD)
+ {
+ 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;
+ }
+
+
+
+ /* ======================================== ULTRAMINE START =====================================*/
+
+
+ public static final int MAX_BLOCK_COORD = 500000;//524288;
+
+ public Chunk getChunkIfExists(int cx, int cz)
+ {
+ return getChunkFromChunkCoords(cx, cz);
+ }
+
+ public Block getBlockIfExists(int x, int y, int z)
+ {
+ if(blockExists(x, y, z))
+ return getBlock(x, y, z);
+ return Blocks.air;
+ }
+
+ public boolean chunkRoundExists(int cx, int cz, int radius)
+ {
+ for(int x = cx - radius; x <= cx + radius; x++)
+ for(int z = cz - radius; z <= cz + radius; z++)
+ if(!chunkExists(x, z)) return false;
+ return true;
+ }
+
+ protected boolean isChunkLoaderEnabled()
+ {
+ return true;
+ }
+
+ protected int getChunkUpdateRadius()
+ {
+ return 7;
+ }
}
\ 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
index cd47fd3..e71d585 100644
--- a/src/main/java/net/minecraft/world/WorldServer.java
+++ b/src/main/java/net/minecraft/world/WorldServer.java
@@ -1,1043 +1,1043 @@
-package net.minecraft.world;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import gnu.trove.iterator.TIntByteIterator;
-import gnu.trove.set.TIntSet;
-import gnu.trove.set.hash.TIntHashSet;
-
-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;
-import org.ultramine.server.WorldsConfig.WorldConfig;
-import org.ultramine.server.WorldsConfig.WorldConfig.Settings.WorldTime;
-import org.ultramine.server.chunk.ChunkHash;
-import org.ultramine.server.chunk.PendingBlockUpdate;
-
-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 TIntSet doneChunks = new TIntHashSet(512);
- 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);
-
- WorldTime time = getConfig().settings.time;
- long curTime = worldInfo.getWorldTime() % 24000;
-
- if(time == WorldTime.DAY && curTime > 10000)
- worldInfo.setWorldTime(worldInfo.getWorldTime() - curTime + 24000 + 1000);
- if(time == WorldTime.NIGHT && (curTime < 14200 || curTime > 21800))
- worldInfo.setWorldTime(worldInfo.getWorldTime() - curTime + 24000 + 14200);
-
- if(time != WorldTime.FIXED && getGameRules().getGameRuleBooleanValue("doDaylightCycle"))
- worldInfo.setWorldTime(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;
-
- doneChunks.retainAll(activeChunkSet.keySet());
- if (doneChunks.size() == activeChunkSet.size())
- {
- doneChunks.clear();
- }
-
- final long startTime = System.nanoTime();
-
- for (TIntByteIterator iter = activeChunkSet.iterator(); iter.hasNext();)
- {
- iter.advance();
- int chunkCoord = iter.key();
- int chunkX = ChunkHash.keyToX(chunkCoord);
- int chunkZ = ChunkHash.keyToZ(chunkCoord);
- int k = chunkX << 4;
- int l = chunkZ << 4;
-
- this.theProfiler.startSection("getChunk");
- Chunk chunk = this.getChunkFromChunkCoords(chunkX, chunkZ);
- chunk.setActive();
- this.theProfiler.startSection("updatePending");
- this.updatePendingOf(chunk);
- 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(chunkCoord))
- {
- 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_)
- {
- //Это не заглушка. Этот метод может использоваться модами по назначению, все работает правильно.
- return false;
- }
-
- 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 x, int y, int z, Block block, int time, int priority)
- {
- //NextTickListEntry nextticklistentry = new NextTickListEntry(x, y, z, block);
- //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 && block.getMaterial() != Material.air)
- {
- if (block.func_149698_L())
- {
- b0 = 8;
-
- if (this.checkChunksExist(x - b0, y - b0, z - b0, x + b0, y + b0, z + b0))
- {
- Block block1 = this.getBlock(x, y, z);
-
- if (block1.getMaterial() != Material.air && block1 == block)
- {
- block1.updateTick(this, x, y, z, this.rand);
- }
- }
-
- return;
- }
-
- time = 1;
- }
-
- Chunk chunk = getChunkIfExists(x >> 4, z >> 4);
-
- if (chunk != null)
- {
- PendingBlockUpdate p = new PendingBlockUpdate(x&15, y, z&15, block, worldInfo.getWorldTotalTime() + (long)time, priority);
- chunk.scheduleBlockUpdate(p, true);
- }
- }
-
- 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_)
- {
- //Данный метод вызывался только при загрузке чанка. Для совместимости с модами, которые неправильно используют этот метод, пытаемся запланировать обновление.
- Chunk chunk = getChunkIfExists(p_147446_1_ >> 4, p_147446_3_ >> 4);
-
- if (chunk != null)
- {
- PendingBlockUpdate p = new PendingBlockUpdate(p_147446_1_&15, p_147446_2_, p_147446_3_&15, p_147446_4_, worldInfo.getWorldTotalTime() + (long)p_147446_5_, p_147446_6_);
- chunk.scheduleBlockUpdate(p, true);
- }
- }
-
- 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)
- {
- //Выполнение отложенных обновлений перенесено в updatePendingOf(Chunk)
- return false;
- }
-
- public List getPendingBlockUpdates(Chunk par1Chunk, boolean par2)
- {
- //Данный метод вызывался только при сохранении чанка. Теперь он не может вызываться нигде, совместимость не предусмотрена.
- logger.warn("Called deprecated method getPendingBlockUpdates", new Throwable());
- return null;
- }
-
- public void updateEntityWithOptionalForce(Entity par1Entity, boolean par2)
- {
- if (!getConfig().mobSpawn.spawnAnimals && (par1Entity instanceof EntityAnimal || par1Entity instanceof EntityWaterMob))
- {
- par1Entity.setDead();
- }
-
- if (!getConfig().mobSpawn.spawnNPCs && 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();
-
- switch(getConfig().settings.weather)
- {
- case NONE:
- if(flag)
- {
- worldInfo.setRainTime(12300);
- worldInfo.setThunderTime(12300);
- worldInfo.setRaining(false);
- worldInfo.setThundering(false);
- prevRainingStrength = rainingStrength = 0F;
- prevThunderingStrength = thunderingStrength = 0F;
- }
- break;
- case THUNDER:
- worldInfo.setThunderTime(12300);
- worldInfo.setThundering(true);
- case RAIN:
- worldInfo.setRainTime(12300);
- worldInfo.setRaining(true);
- case NORMAL:
- 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().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(2, 0.0F), provider.dimensionId);
- }
- else
- {
- this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(1, 0.0F), provider.dimensionId);
- }
-
- this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), provider.dimensionId);
- this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), provider.dimensionId);
- }
- }
-
- 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();
- }
- }
-
- /* ======================================== ULTRAMINE START =====================================*/
-
- private WorldConfig config;
-
- public void checkSessionLock() throws MinecraftException
- {
- //Removes world lock checking on server
- }
-
- public Chunk getChunkIfExists(int cx, int cz)
- {
- return theChunkProviderServer.getChunkIfExists(cx, cz);
- }
-
- private void updatePendingOf(Chunk chunk)
- {
- long time = worldInfo.getWorldTotalTime();
- int x = chunk.xPosition << 4;
- int z = chunk.zPosition << 4;
-
- PendingBlockUpdate p;
- while((p = chunk.pollPending(time)) != null)
- {
- updateBlock(x + p.x, p.y, z + p.z, p.getBlock());
- }
- }
-
- private void updateBlock(int x, int y, int z, Block block1)
- {
- Block block = this.getBlock(x, y, z);
-
- if (block.getMaterial() != Material.air && Block.isEqualTo(block, block1))
- {
- try
- {
- block.updateTick(this, x, y, z, 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(x, y, z);
- }
- catch (Throwable throwable)
- {
- k = -1;
- }
-
- CrashReportCategory.func_147153_a(crashreportcategory, x, y, z, block, k);
- throw new ReportedException(crashreport);
- }
- }
- }
-
- public void setConfig(WorldConfig config)
- {
- this.config = config;
- }
-
- public WorldConfig getConfig()
- {
- return config;
- }
-
- protected boolean isChunkLoaderEnabled()
- {
- return config.chunkLoading.enableChunkLoaders;
- }
-
- protected int getChunkUpdateRadius()
- {
- return config.chunkLoading.chunkUpdateRadius;
- }
+package net.minecraft.world;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gnu.trove.iterator.TIntByteIterator;
+import gnu.trove.set.TIntSet;
+import gnu.trove.set.hash.TIntHashSet;
+
+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;
+import org.ultramine.server.WorldsConfig.WorldConfig;
+import org.ultramine.server.WorldsConfig.WorldConfig.Settings.WorldTime;
+import org.ultramine.server.chunk.ChunkHash;
+import org.ultramine.server.chunk.PendingBlockUpdate;
+
+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 TIntSet doneChunks = new TIntHashSet(512);
+ 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);
+
+ WorldTime time = getConfig().settings.time;
+ long curTime = worldInfo.getWorldTime() % 24000;
+
+ if(time == WorldTime.DAY && curTime > 10000)
+ worldInfo.setWorldTime(worldInfo.getWorldTime() - curTime + 24000 + 1000);
+ if(time == WorldTime.NIGHT && (curTime < 14200 || curTime > 21800))
+ worldInfo.setWorldTime(worldInfo.getWorldTime() - curTime + 24000 + 14200);
+
+ if(time != WorldTime.FIXED && getGameRules().getGameRuleBooleanValue("doDaylightCycle"))
+ worldInfo.setWorldTime(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;
+
+ doneChunks.retainAll(activeChunkSet.keySet());
+ if (doneChunks.size() == activeChunkSet.size())
+ {
+ doneChunks.clear();
+ }
+
+ final long startTime = System.nanoTime();
+
+ for (TIntByteIterator iter = activeChunkSet.iterator(); iter.hasNext();)
+ {
+ iter.advance();
+ int chunkCoord = iter.key();
+ int chunkX = ChunkHash.keyToX(chunkCoord);
+ int chunkZ = ChunkHash.keyToZ(chunkCoord);
+ int k = chunkX << 4;
+ int l = chunkZ << 4;
+
+ this.theProfiler.startSection("getChunk");
+ Chunk chunk = this.getChunkFromChunkCoords(chunkX, chunkZ);
+ chunk.setActive();
+ this.theProfiler.startSection("updatePending");
+ this.updatePendingOf(chunk);
+ 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(chunkCoord))
+ {
+ 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_)
+ {
+ //Это не заглушка. Этот метод может использоваться модами по назначению, все работает правильно.
+ return false;
+ }
+
+ 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 x, int y, int z, Block block, int time, int priority)
+ {
+ //NextTickListEntry nextticklistentry = new NextTickListEntry(x, y, z, block);
+ //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 && block.getMaterial() != Material.air)
+ {
+ if (block.func_149698_L())
+ {
+ b0 = 8;
+
+ if (this.checkChunksExist(x - b0, y - b0, z - b0, x + b0, y + b0, z + b0))
+ {
+ Block block1 = this.getBlock(x, y, z);
+
+ if (block1.getMaterial() != Material.air && block1 == block)
+ {
+ block1.updateTick(this, x, y, z, this.rand);
+ }
+ }
+
+ return;
+ }
+
+ time = 1;
+ }
+
+ Chunk chunk = getChunkIfExists(x >> 4, z >> 4);
+
+ if (chunk != null)
+ {
+ PendingBlockUpdate p = new PendingBlockUpdate(x&15, y, z&15, block, worldInfo.getWorldTotalTime() + (long)time, priority);
+ chunk.scheduleBlockUpdate(p, true);
+ }
+ }
+
+ 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_)
+ {
+ //Данный метод вызывался только при загрузке чанка. Для совместимости с модами, которые неправильно используют этот метод, пытаемся запланировать обновление.
+ Chunk chunk = getChunkIfExists(p_147446_1_ >> 4, p_147446_3_ >> 4);
+
+ if (chunk != null)
+ {
+ PendingBlockUpdate p = new PendingBlockUpdate(p_147446_1_&15, p_147446_2_, p_147446_3_&15, p_147446_4_, worldInfo.getWorldTotalTime() + (long)p_147446_5_, p_147446_6_);
+ chunk.scheduleBlockUpdate(p, true);
+ }
+ }
+
+ 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)
+ {
+ //Выполнение отложенных обновлений перенесено в updatePendingOf(Chunk)
+ return false;
+ }
+
+ public List getPendingBlockUpdates(Chunk par1Chunk, boolean par2)
+ {
+ //Данный метод вызывался только при сохранении чанка. Теперь он не может вызываться нигде, совместимость не предусмотрена.
+ logger.warn("Called deprecated method getPendingBlockUpdates", new Throwable());
+ return null;
+ }
+
+ public void updateEntityWithOptionalForce(Entity par1Entity, boolean par2)
+ {
+ if (!getConfig().mobSpawn.spawnAnimals && (par1Entity instanceof EntityAnimal || par1Entity instanceof EntityWaterMob))
+ {
+ par1Entity.setDead();
+ }
+
+ if (!getConfig().mobSpawn.spawnNPCs && 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();
+
+ switch(getConfig().settings.weather)
+ {
+ case NONE:
+ if(flag)
+ {
+ worldInfo.setRainTime(12300);
+ worldInfo.setThunderTime(12300);
+ worldInfo.setRaining(false);
+ worldInfo.setThundering(false);
+ prevRainingStrength = rainingStrength = 0F;
+ prevThunderingStrength = thunderingStrength = 0F;
+ }
+ break;
+ case THUNDER:
+ worldInfo.setThunderTime(12300);
+ worldInfo.setThundering(true);
+ case RAIN:
+ worldInfo.setRainTime(12300);
+ worldInfo.setRaining(true);
+ case NORMAL:
+ 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().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(2, 0.0F), provider.dimensionId);
+ }
+ else
+ {
+ this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(1, 0.0F), provider.dimensionId);
+ }
+
+ this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), provider.dimensionId);
+ this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), provider.dimensionId);
+ }
+ }
+
+ 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();
+ }
+ }
+
+ /* ======================================== ULTRAMINE START =====================================*/
+
+ private WorldConfig config;
+
+ public void checkSessionLock() throws MinecraftException
+ {
+ //Removes world lock checking on server
+ }
+
+ public Chunk getChunkIfExists(int cx, int cz)
+ {
+ return theChunkProviderServer.getChunkIfExists(cx, cz);
+ }
+
+ private void updatePendingOf(Chunk chunk)
+ {
+ long time = worldInfo.getWorldTotalTime();
+ int x = chunk.xPosition << 4;
+ int z = chunk.zPosition << 4;
+
+ PendingBlockUpdate p;
+ while((p = chunk.pollPending(time)) != null)
+ {
+ updateBlock(x + p.x, p.y, z + p.z, p.getBlock());
+ }
+ }
+
+ private void updateBlock(int x, int y, int z, Block block1)
+ {
+ Block block = this.getBlock(x, y, z);
+
+ if (block.getMaterial() != Material.air && Block.isEqualTo(block, block1))
+ {
+ try
+ {
+ block.updateTick(this, x, y, z, 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(x, y, z);
+ }
+ catch (Throwable throwable)
+ {
+ k = -1;
+ }
+
+ CrashReportCategory.func_147153_a(crashreportcategory, x, y, z, block, k);
+ throw new ReportedException(crashreport);
+ }
+ }
+ }
+
+ public void setConfig(WorldConfig config)
+ {
+ this.config = config;
+ }
+
+ public WorldConfig getConfig()
+ {
+ return config;
+ }
+
+ protected boolean isChunkLoaderEnabled()
+ {
+ return config.chunkLoading.enableChunkLoaders;
+ }
+
+ protected int getChunkUpdateRadius()
+ {
+ return config.chunkLoading.chunkUpdateRadius;
+ }
}
\ 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
index 796d4c2..e272fa8 100644
--- a/src/main/java/net/minecraft/world/chunk/storage/AnvilSaveHandler.java
+++ b/src/main/java/net/minecraft/world/chunk/storage/AnvilSaveHandler.java
@@ -1,66 +1,66 @@
-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 (!isSingleStorage && 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();
- }
-
- /* ======================================== ULTRAMINE START =====================================*/
-
- private boolean isSingleStorage;
-
- public void setSingleStorage()
- {
- isSingleStorage = true;
- }
+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 (!isSingleStorage && 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();
+ }
+
+ /* ======================================== ULTRAMINE START =====================================*/
+
+ private boolean isSingleStorage;
+
+ public void setSingleStorage()
+ {
+ isSingleStorage = true;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/net/minecraftforge/common/DimensionManager.java b/src/main/java/net/minecraftforge/common/DimensionManager.java
index 69b12a7..82b3587 100644
--- a/src/main/java/net/minecraftforge/common/DimensionManager.java
+++ b/src/main/java/net/minecraftforge/common/DimensionManager.java
@@ -1,431 +1,431 @@
-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 extends WorldProvider> 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();
- mcServer.getMultiWorld().initDimension(dim);
- /*
- 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)
- {
+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 extends WorldProvider> 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();
+ mcServer.getMultiWorld().initDimension(dim);
+ /*
+ 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)
+ {
dimensionMap.clear();
- if (compoundTag == null)
- {
- 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;
- }
- }
-}
+ if (compoundTag == null)
+ {
+ 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/org/ultramine/commands/CommandContext.java b/src/main/java/org/ultramine/commands/CommandContext.java
index 6a03abc..6708fe9 100644
--- a/src/main/java/org/ultramine/commands/CommandContext.java
+++ b/src/main/java/org/ultramine/commands/CommandContext.java
@@ -1,318 +1,318 @@
-package org.ultramine.commands;
-
-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.entity.player.EntityPlayer;
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.item.Item;
-import net.minecraft.server.MinecraftServer;
-import net.minecraft.util.ChatComponentTranslation;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.util.IChatComponent;
-import net.minecraft.world.WorldServer;
-
-import org.ultramine.server.PermissionHandler;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class CommandContext
-{
- private ICommandSender sender;
- private String[] args;
- private IExtendedCommand command;
- private Map argumentMap;
- private int lastArgumentNum;
- private String actionName;
- private ICommandHandler actionHandler;
-
- private CommandContext(IExtendedCommand command, ICommandSender sender, String[] args)
- {
- this.sender = sender;
- this.args = args;
- this.command = command;
- this.argumentMap = new HashMap(args.length);
- this.actionName = "";
- this.lastArgumentNum = args.length - 1;
- }
-
- public Argument get(String key)
- {
- if (!argumentMap.containsKey(key))
- throwBadUsage();
-
- return argumentMap.get(key);
- }
-
- public Argument get(int num)
- {
- if (num < 0 || num >= args.length)
- throwBadUsage();
-
- return new Argument(num);
- }
-
- public boolean contains(String key)
- {
- return argumentMap.containsKey(key);
- }
-
- public Argument set(String key, String value)
- {
- Argument arg = new Argument(value);
- argumentMap.put(key, arg);
- return arg;
- }
-
- public String getAction()
- {
- return actionName;
- }
-
- public boolean actionIs(String action)
- {
- return actionName.equalsIgnoreCase(action);
- }
-
- public void doAction()
- {
- if (actionHandler != null)
- actionHandler.processCommand(this);
- }
-
- public ICommandSender getSender()
- {
- return sender;
- }
-
- public boolean senderIsServer()
- {
- return !(sender instanceof EntityPlayer);
- }
-
- public EntityPlayerMP getSenderAsPlayer()
- {
- return CommandBase.getCommandSenderAsPlayer(sender);
- }
-
- public void notifyAdmins(String messageKey, Object... messageArgs)
- {
- CommandBase.notifyAdmins(sender, messageKey, messageArgs);
- }
-
- public void checkSenderPermission(String permission)
- {
- if (!senderIsServer() && !PermissionHandler.getInstance().has(sender, permission))
- throw new CommandException("commands.generic.permission");
- }
-
- public void checkSenderPermissionInWorld(String world, String permission)
- {
- if (!senderIsServer() && !PermissionHandler.getInstance().has(world, sender.getCommandSenderName(), permission))
- throw new CommandException("commands.generic.permission");
- }
-
- public void sendMessage(EnumChatFormatting color, String msg, Object... args)
- {
- ChatComponentTranslation comp = new ChatComponentTranslation(msg, args);
- comp.getChatStyle().setColor(color);
- sender.addChatMessage(comp);
- }
-
- public void throwBadUsage()
- {
- throw new WrongUsageException(command.getCommandUsage(sender));
- }
-
- public String[] getArgs()
- {
- return args;
- }
-
- public IExtendedCommand getCommand()
- {
- return command;
- }
-
- public class Argument
- {
- private int num;
- private boolean last;
- private String value;
-
- private Argument(int num)
- {
- this.value = args[num];
- this.num = num;
- this.last = num == lastArgumentNum;
- }
-
- private Argument(int num, boolean last)
- {
- this.value = args[num];
- this.num = num;
- this.last = last;
- }
-
- private Argument(String value)
- {
- this.value = value;
- this.num = -1;
- this.last = false;
- }
-
- private String[] args()
- {
- if (num >= 0)
- return args;
- else
- return new String[] {value};
- }
-
- private int num()
- {
- return Math.max(num, 0);
- }
-
- public String asString()
- {
- if (last)
- return CommandBase.func_82360_a(sender, args(), num());
- else
- return value;
- }
-
- public Argument[] asArray()
- {
- if (num < 0)
- return new Argument[] {this};
-
- Argument[] result = new Argument[args.length - num];
- for (int i = num; i < args.length; i++)
- result[i-num] = new Argument(i, false);
- return result;
- }
-
- public int asInt()
- {
- return CommandBase.parseInt(sender, value);
- }
-
- public int asInt(int minBound)
- {
- return CommandBase.parseIntWithMin(sender, value, minBound);
- }
-
- public int asInt(int minBound, int maxBound)
- {
- return CommandBase.parseIntBounded(sender, value, minBound, maxBound);
- }
-
- public double asDouble()
- {
- return CommandBase.parseDouble(sender, value);
- }
-
- public double asDouble(double minBound)
- {
- return CommandBase.parseDoubleWithMin(sender, value, minBound);
- }
-
- public double asDouble(double minBound, double maxBound)
- {
- return CommandBase.parseDoubleBounded(sender, value, minBound, maxBound);
- }
-
- public boolean asBoolean()
- {
- return CommandBase.parseBoolean(sender, value);
- }
-
- public EntityPlayerMP asPlayer()
- {
- return CommandBase.getPlayer(sender, value);
- }
-
- public WorldServer asWorld()
- {
- WorldServer world = MinecraftServer.getServer().getMultiWorld().getWorldByNameOrID(value);
- if(world == null)
- throw new CommandException("commands.generic.world.invalid", value);
- return world;
- }
-
- public IChatComponent asChatComponent(boolean emphasizePlayers)
- {
- return CommandBase.func_147176_a(sender, args(), num(), emphasizePlayers);
- }
-
- public double asCoordinate(double original)
- {
- return CommandBase.func_110666_a(sender, original, value);
- }
-
- public double asCoordinate(double original, int minBound, int maxBound)
- {
- return CommandBase.func_110665_a(sender, original, value, minBound, maxBound);
- }
-
- public Item asItem()
- {
- return CommandBase.getItemByText(sender, value);
- }
-
- public Block asBlock()
- {
- return CommandBase.getBlockByText(sender, value);
- }
- }
-
- public static class Builder
- {
- private CommandContext context;
-
- public Builder(IExtendedCommand command, ICommandSender sender, String[] args)
- {
- context = new CommandContext(command, sender, args);
- }
-
- public Builder resolveArguments(List names)
- {
- context.lastArgumentNum = names.size();
- Map nameCount = new HashMap();
- for (int i = 0; i < names.size(); i++)
- {
- String name = names.get(i);
-
- if (name == null || name.isEmpty())
- continue;
-
- if (context.argumentMap.containsKey(name))
- {
- Integer count = nameCount.containsKey(name) ? nameCount.get(name) + 1 : 2;
- nameCount.put(name, count);
- name = name + count.toString();
- }
-
- context.argumentMap.put(name, context.new Argument(i));
- }
- return this;
- }
-
- public Builder setAction(String actionName, ICommandHandler actionHandler)
- {
- context.actionName = actionName;
- context.actionHandler = actionHandler;
- return this;
- }
-
- public CommandContext build()
- {
- return context;
- }
- }
-}
+package org.ultramine.commands;
+
+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.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.item.Item;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.util.ChatComponentTranslation;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.IChatComponent;
+import net.minecraft.world.WorldServer;
+
+import org.ultramine.server.PermissionHandler;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class CommandContext
+{
+ private ICommandSender sender;
+ private String[] args;
+ private IExtendedCommand command;
+ private Map argumentMap;
+ private int lastArgumentNum;
+ private String actionName;
+ private ICommandHandler actionHandler;
+
+ private CommandContext(IExtendedCommand command, ICommandSender sender, String[] args)
+ {
+ this.sender = sender;
+ this.args = args;
+ this.command = command;
+ this.argumentMap = new HashMap(args.length);
+ this.actionName = "";
+ this.lastArgumentNum = args.length - 1;
+ }
+
+ public Argument get(String key)
+ {
+ if (!argumentMap.containsKey(key))
+ throwBadUsage();
+
+ return argumentMap.get(key);
+ }
+
+ public Argument get(int num)
+ {
+ if (num < 0 || num >= args.length)
+ throwBadUsage();
+
+ return new Argument(num);
+ }
+
+ public boolean contains(String key)
+ {
+ return argumentMap.containsKey(key);
+ }
+
+ public Argument set(String key, String value)
+ {
+ Argument arg = new Argument(value);
+ argumentMap.put(key, arg);
+ return arg;
+ }
+
+ public String getAction()
+ {
+ return actionName;
+ }
+
+ public boolean actionIs(String action)
+ {
+ return actionName.equalsIgnoreCase(action);
+ }
+
+ public void doAction()
+ {
+ if (actionHandler != null)
+ actionHandler.processCommand(this);
+ }
+
+ public ICommandSender getSender()
+ {
+ return sender;
+ }
+
+ public boolean senderIsServer()
+ {
+ return !(sender instanceof EntityPlayer);
+ }
+
+ public EntityPlayerMP getSenderAsPlayer()
+ {
+ return CommandBase.getCommandSenderAsPlayer(sender);
+ }
+
+ public void notifyAdmins(String messageKey, Object... messageArgs)
+ {
+ CommandBase.notifyAdmins(sender, messageKey, messageArgs);
+ }
+
+ public void checkSenderPermission(String permission)
+ {
+ if (!senderIsServer() && !PermissionHandler.getInstance().has(sender, permission))
+ throw new CommandException("commands.generic.permission");
+ }
+
+ public void checkSenderPermissionInWorld(String world, String permission)
+ {
+ if (!senderIsServer() && !PermissionHandler.getInstance().has(world, sender.getCommandSenderName(), permission))
+ throw new CommandException("commands.generic.permission");
+ }
+
+ public void sendMessage(EnumChatFormatting color, String msg, Object... args)
+ {
+ ChatComponentTranslation comp = new ChatComponentTranslation(msg, args);
+ comp.getChatStyle().setColor(color);
+ sender.addChatMessage(comp);
+ }
+
+ public void throwBadUsage()
+ {
+ throw new WrongUsageException(command.getCommandUsage(sender));
+ }
+
+ public String[] getArgs()
+ {
+ return args;
+ }
+
+ public IExtendedCommand getCommand()
+ {
+ return command;
+ }
+
+ public class Argument
+ {
+ private int num;
+ private boolean last;
+ private String value;
+
+ private Argument(int num)
+ {
+ this.value = args[num];
+ this.num = num;
+ this.last = num == lastArgumentNum;
+ }
+
+ private Argument(int num, boolean last)
+ {
+ this.value = args[num];
+ this.num = num;
+ this.last = last;
+ }
+
+ private Argument(String value)
+ {
+ this.value = value;
+ this.num = -1;
+ this.last = false;
+ }
+
+ private String[] args()
+ {
+ if (num >= 0)
+ return args;
+ else
+ return new String[] {value};
+ }
+
+ private int num()
+ {
+ return Math.max(num, 0);
+ }
+
+ public String asString()
+ {
+ if (last)
+ return CommandBase.func_82360_a(sender, args(), num());
+ else
+ return value;
+ }
+
+ public Argument[] asArray()
+ {
+ if (num < 0)
+ return new Argument[] {this};
+
+ Argument[] result = new Argument[args.length - num];
+ for (int i = num; i < args.length; i++)
+ result[i-num] = new Argument(i, false);
+ return result;
+ }
+
+ public int asInt()
+ {
+ return CommandBase.parseInt(sender, value);
+ }
+
+ public int asInt(int minBound)
+ {
+ return CommandBase.parseIntWithMin(sender, value, minBound);
+ }
+
+ public int asInt(int minBound, int maxBound)
+ {
+ return CommandBase.parseIntBounded(sender, value, minBound, maxBound);
+ }
+
+ public double asDouble()
+ {
+ return CommandBase.parseDouble(sender, value);
+ }
+
+ public double asDouble(double minBound)
+ {
+ return CommandBase.parseDoubleWithMin(sender, value, minBound);
+ }
+
+ public double asDouble(double minBound, double maxBound)
+ {
+ return CommandBase.parseDoubleBounded(sender, value, minBound, maxBound);
+ }
+
+ public boolean asBoolean()
+ {
+ return CommandBase.parseBoolean(sender, value);
+ }
+
+ public EntityPlayerMP asPlayer()
+ {
+ return CommandBase.getPlayer(sender, value);
+ }
+
+ public WorldServer asWorld()
+ {
+ WorldServer world = MinecraftServer.getServer().getMultiWorld().getWorldByNameOrID(value);
+ if(world == null)
+ throw new CommandException("commands.generic.world.invalid", value);
+ return world;
+ }
+
+ public IChatComponent asChatComponent(boolean emphasizePlayers)
+ {
+ return CommandBase.func_147176_a(sender, args(), num(), emphasizePlayers);
+ }
+
+ public double asCoordinate(double original)
+ {
+ return CommandBase.func_110666_a(sender, original, value);
+ }
+
+ public double asCoordinate(double original, int minBound, int maxBound)
+ {
+ return CommandBase.func_110665_a(sender, original, value, minBound, maxBound);
+ }
+
+ public Item asItem()
+ {
+ return CommandBase.getItemByText(sender, value);
+ }
+
+ public Block asBlock()
+ {
+ return CommandBase.getBlockByText(sender, value);
+ }
+ }
+
+ public static class Builder
+ {
+ private CommandContext context;
+
+ public Builder(IExtendedCommand command, ICommandSender sender, String[] args)
+ {
+ context = new CommandContext(command, sender, args);
+ }
+
+ public Builder resolveArguments(List names)
+ {
+ context.lastArgumentNum = names.size();
+ Map nameCount = new HashMap();
+ for (int i = 0; i < names.size(); i++)
+ {
+ String name = names.get(i);
+
+ if (name == null || name.isEmpty())
+ continue;
+
+ if (context.argumentMap.containsKey(name))
+ {
+ Integer count = nameCount.containsKey(name) ? nameCount.get(name) + 1 : 2;
+ nameCount.put(name, count);
+ name = name + count.toString();
+ }
+
+ context.argumentMap.put(name, context.new Argument(i));
+ }
+ return this;
+ }
+
+ public Builder setAction(String actionName, ICommandHandler actionHandler)
+ {
+ context.actionName = actionName;
+ context.actionHandler = actionHandler;
+ return this;
+ }
+
+ public CommandContext build()
+ {
+ return context;
+ }
+ }
+}
diff --git a/src/main/java/org/ultramine/commands/basic/VanillaCommands.java b/src/main/java/org/ultramine/commands/basic/VanillaCommands.java
index 586add4..eef2842 100644
--- a/src/main/java/org/ultramine/commands/basic/VanillaCommands.java
+++ b/src/main/java/org/ultramine/commands/basic/VanillaCommands.java
@@ -1,75 +1,75 @@
-package org.ultramine.commands.basic;
-
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.server.MinecraftServer;
-import net.minecraft.util.ChatComponentTranslation;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.world.EnumDifficulty;
-import net.minecraft.world.WorldServer;
-
-import org.ultramine.commands.Command;
-import org.ultramine.commands.CommandContext;
-import org.ultramine.server.Teleporter;
-import org.ultramine.server.util.BasicTypeParser;
-
-public class VanillaCommands
-{
- @Command(
- name = "tp",
- group = "vanilla",
- aliases = {"tppos", "tpposp", "tpto"},
- permissions = {"command.vanilla.tp"},
- syntax = {
- "",
- " ",
- "<%x> <%y> <%z>",
- " <%x> <%y> <%z>",
- " <%x> <%y> <%z>",
- " <%x> <%y> <%z>"
- }
- )
- public static void tp(CommandContext context)
- {
- EntityPlayerMP target = context.contains("target") ? context.get("target").asPlayer() : context.getSenderAsPlayer();
- if(context.contains("dst"))
- {
- EntityPlayerMP dst = context.get("dst").asPlayer();
- Teleporter.tpNow(target, dst);
- context.sendMessage(EnumChatFormatting.GOLD, "command.tp.success.player", target.getCommandSenderName(), dst.getCommandSenderName());
- }
- else if(context.contains("x") && context.contains("y") && context.contains("z"))
- {
- WorldServer world = context.contains("world") ? context.get("world").asWorld() : target.getServerForPlayer();
- double x = context.get("x").asCoordinate(target.posX);
- double y = context.get("y").asCoordinate(target.posY);
- double z = context.get("z").asCoordinate(target.posZ);
- Teleporter.tpNow(target, world.provider.dimensionId, x, y, z);
- context.sendMessage(EnumChatFormatting.GOLD, "command.tp.success.coordinate",
- target.getCommandSenderName(), world.getWorldInfo().getWorldName(), x, y, z);
- }
- }
-
- @Command(
- name = "difficulty",
- group = "vanilla",
- permissions = {"command.vanilla.difficulty"},
- syntax = {
- "",
- " "
- }
- )
- public static void difficulty(CommandContext ctx)
- {
- WorldServer world = ctx.contains("world") ? ctx.get("world").asWorld() : ctx.getSenderAsPlayer().getServerForPlayer();
- EnumDifficulty difficulty = BasicTypeParser.parseDifficulty(ctx.get("difficulty").asString());
- if(difficulty == null) ctx.throwBadUsage();
- ctx.notifyAdmins("command.difficulty.success", world.getWorldInfo().getWorldName(),
- new ChatComponentTranslation(world.difficultySetting.getDifficultyResourceKey()),
- new ChatComponentTranslation(difficulty.getDifficultyResourceKey()));
- MinecraftServer server = MinecraftServer.getServer();
- if(server.isSinglePlayer())
- server.func_147139_a(difficulty);
- else
- world.difficultySetting = difficulty;
- }
-}
+package org.ultramine.commands.basic;
+
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.util.ChatComponentTranslation;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.world.EnumDifficulty;
+import net.minecraft.world.WorldServer;
+
+import org.ultramine.commands.Command;
+import org.ultramine.commands.CommandContext;
+import org.ultramine.server.Teleporter;
+import org.ultramine.server.util.BasicTypeParser;
+
+public class VanillaCommands
+{
+ @Command(
+ name = "tp",
+ group = "vanilla",
+ aliases = {"tppos", "tpposp", "tpto"},
+ permissions = {"command.vanilla.tp"},
+ syntax = {
+ "",
+ " ",
+ "<%x> <%y> <%z>",
+ " <%x> <%y> <%z>",
+ " <%x> <%y> <%z>",
+ " <%x> <%y> <%z>"
+ }
+ )
+ public static void tp(CommandContext context)
+ {
+ EntityPlayerMP target = context.contains("target") ? context.get("target").asPlayer() : context.getSenderAsPlayer();
+ if(context.contains("dst"))
+ {
+ EntityPlayerMP dst = context.get("dst").asPlayer();
+ Teleporter.tpNow(target, dst);
+ context.sendMessage(EnumChatFormatting.GOLD, "command.tp.success.player", target.getCommandSenderName(), dst.getCommandSenderName());
+ }
+ else if(context.contains("x") && context.contains("y") && context.contains("z"))
+ {
+ WorldServer world = context.contains("world") ? context.get("world").asWorld() : target.getServerForPlayer();
+ double x = context.get("x").asCoordinate(target.posX);
+ double y = context.get("y").asCoordinate(target.posY);
+ double z = context.get("z").asCoordinate(target.posZ);
+ Teleporter.tpNow(target, world.provider.dimensionId, x, y, z);
+ context.sendMessage(EnumChatFormatting.GOLD, "command.tp.success.coordinate",
+ target.getCommandSenderName(), world.getWorldInfo().getWorldName(), x, y, z);
+ }
+ }
+
+ @Command(
+ name = "difficulty",
+ group = "vanilla",
+ permissions = {"command.vanilla.difficulty"},
+ syntax = {
+ "",
+ " "
+ }
+ )
+ public static void difficulty(CommandContext ctx)
+ {
+ WorldServer world = ctx.contains("world") ? ctx.get("world").asWorld() : ctx.getSenderAsPlayer().getServerForPlayer();
+ EnumDifficulty difficulty = BasicTypeParser.parseDifficulty(ctx.get("difficulty").asString());
+ if(difficulty == null) ctx.throwBadUsage();
+ ctx.notifyAdmins("command.difficulty.success", world.getWorldInfo().getWorldName(),
+ new ChatComponentTranslation(world.difficultySetting.getDifficultyResourceKey()),
+ new ChatComponentTranslation(difficulty.getDifficultyResourceKey()));
+ MinecraftServer server = MinecraftServer.getServer();
+ if(server.isSinglePlayer())
+ server.func_147139_a(difficulty);
+ else
+ world.difficultySetting = difficulty;
+ }
+}
diff --git a/src/main/java/org/ultramine/commands/syntax/DefaultCompleters.java b/src/main/java/org/ultramine/commands/syntax/DefaultCompleters.java
index dd51dcb..6f925ab 100644
--- a/src/main/java/org/ultramine/commands/syntax/DefaultCompleters.java
+++ b/src/main/java/org/ultramine/commands/syntax/DefaultCompleters.java
@@ -1,82 +1,82 @@
-package org.ultramine.commands.syntax;
-
-import net.minecraft.block.Block;
-import net.minecraft.command.CommandBase;
-import net.minecraft.entity.EntityList;
-import net.minecraft.item.Item;
-import net.minecraft.server.MinecraftServer;
-import org.ultramine.server.util.BasicTypeParser;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class DefaultCompleters
-{
- @ArgumentCompleter(value = "player", isUsername = true)
- public static List player(String val, String[] args)
- {
- return filterArray(val, MinecraftServer.getServer().getAllUsernames());
- }
-
- @ArgumentCompleter("item")
- public static List item(String val, String[] args)
- {
- return filterCollection(val, Item.itemRegistry.getKeys());
- }
-
- @ArgumentCompleter("block")
- public static List block(String val, String[] args)
- {
- return filterCollection(val, Block.blockRegistry.getKeys());
- }
-
- @ArgumentCompleter("entity")
- public static List entity(String val, String[] args)
- {
- return filterCollection(val, EntityList.func_151515_b());
- }
-
- @ArgumentCompleter("list")
- public static List list(String val, String[] args)
- {
- return filterArray(val, args);
- }
-
- @ArgumentCompleter("world")
- public static List world(String val, String[] args)
- {
- return filterCollection(val, MinecraftServer.getServer().getMultiWorld().getAllNames());
- }
-
- @ArgumentValidator("world")
- public static boolean world_validator(String val, String[] args)
- {
- return BasicTypeParser.isInt(val) || MinecraftServer.getServer().getMultiWorld().getAllNames().contains(val);
- }
-
- public static List filterArray(String filter, String[] strings)
- {
- List result = new ArrayList();
-
- for (String str : strings)
- {
- if (CommandBase.doesStringStartWith(filter, str))
- result.add(str);
- }
-
- return result;
- }
-
- public static List filterCollection(String filter, Iterable iterable)
- {
- List result = new ArrayList();
-
- for (String str : iterable)
- {
- if (CommandBase.doesStringStartWith(filter, str))
- result.add(str);
- }
-
- return result;
- }
-}
+package org.ultramine.commands.syntax;
+
+import net.minecraft.block.Block;
+import net.minecraft.command.CommandBase;
+import net.minecraft.entity.EntityList;
+import net.minecraft.item.Item;
+import net.minecraft.server.MinecraftServer;
+import org.ultramine.server.util.BasicTypeParser;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DefaultCompleters
+{
+ @ArgumentCompleter(value = "player", isUsername = true)
+ public static List player(String val, String[] args)
+ {
+ return filterArray(val, MinecraftServer.getServer().getAllUsernames());
+ }
+
+ @ArgumentCompleter("item")
+ public static List item(String val, String[] args)
+ {
+ return filterCollection(val, Item.itemRegistry.getKeys());
+ }
+
+ @ArgumentCompleter("block")
+ public static List block(String val, String[] args)
+ {
+ return filterCollection(val, Block.blockRegistry.getKeys());
+ }
+
+ @ArgumentCompleter("entity")
+ public static List entity(String val, String[] args)
+ {
+ return filterCollection(val, EntityList.func_151515_b());
+ }
+
+ @ArgumentCompleter("list")
+ public static List list(String val, String[] args)
+ {
+ return filterArray(val, args);
+ }
+
+ @ArgumentCompleter("world")
+ public static List world(String val, String[] args)
+ {
+ return filterCollection(val, MinecraftServer.getServer().getMultiWorld().getAllNames());
+ }
+
+ @ArgumentValidator("world")
+ public static boolean world_validator(String val, String[] args)
+ {
+ return BasicTypeParser.isInt(val) || MinecraftServer.getServer().getMultiWorld().getAllNames().contains(val);
+ }
+
+ public static List filterArray(String filter, String[] strings)
+ {
+ List result = new ArrayList();
+
+ for (String str : strings)
+ {
+ if (CommandBase.doesStringStartWith(filter, str))
+ result.add(str);
+ }
+
+ return result;
+ }
+
+ public static List filterCollection(String filter, Iterable iterable)
+ {
+ List result = new ArrayList();
+
+ for (String str : iterable)
+ {
+ if (CommandBase.doesStringStartWith(filter, str))
+ result.add(str);
+ }
+
+ return result;
+ }
+}
diff --git a/src/main/java/org/ultramine/server/ConfigurationHandler.java b/src/main/java/org/ultramine/server/ConfigurationHandler.java
index 364f2ab..5f96287 100644
--- a/src/main/java/org/ultramine/server/ConfigurationHandler.java
+++ b/src/main/java/org/ultramine/server/ConfigurationHandler.java
@@ -1,69 +1,69 @@
-package org.ultramine.server;
-
-import java.io.File;
-import java.util.Random;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.ultramine.server.util.Resources;
-import org.ultramine.server.util.YamlConfigProvider;
-
-import cpw.mods.fml.relauncher.FMLLaunchHandler;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-
-@SideOnly(Side.SERVER)
-public class ConfigurationHandler
-{
- public static Logger log = LogManager.getLogger();
-
- private static File settingsDir = new File(FMLLaunchHandler.getMinecraftHome(), "settings");
- private static File worldsDir = new File(FMLLaunchHandler.getMinecraftHome(), "worlds");
-
- private static File serverConfigFile = new File(getSettingDir(), "server.yml");
- private static File worldsConfigFile = new File(getSettingDir(), "worlds.yml");
-
- private static UltramineServerConfig serverConfig;
- private static WorldsConfig worldsConfig;
-
- static
- {
- if(!settingsDir.exists()) settingsDir.mkdir();
- if(!worldsDir.exists()) worldsDir.mkdir();
- }
-
- public static void load()
- {
- serverConfig = YamlConfigProvider.getOrCreateConfig(serverConfigFile, UltramineServerConfig.class);
-
- if(!worldsConfigFile.exists())
- YamlConfigProvider.writeFile(worldsConfigFile, Resources.getAsString("/org/ultramine/defaults/defaultworlds.yml")
- .replace("{seed}", Long.toString(Math.abs(new Random().nextLong()))));
- worldsConfig = YamlConfigProvider.readConfig(worldsConfigFile, WorldsConfig.class);
- }
-
- public static File getSettingDir()
- {
- return settingsDir;
- }
-
- public static File getWorldsDir()
- {
- return worldsDir;
- }
-
- public static UltramineServerConfig getServerConfig()
- {
- return serverConfig;
- }
-
- public static WorldsConfig getWorldsConfig()
- {
- return worldsConfig;
- }
-
- public static void saveServerConfig()
- {
- YamlConfigProvider.saveConfig(serverConfigFile, serverConfig);
- }
-}
+package org.ultramine.server;
+
+import java.io.File;
+import java.util.Random;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.ultramine.server.util.Resources;
+import org.ultramine.server.util.YamlConfigProvider;
+
+import cpw.mods.fml.relauncher.FMLLaunchHandler;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+@SideOnly(Side.SERVER)
+public class ConfigurationHandler
+{
+ public static Logger log = LogManager.getLogger();
+
+ private static File settingsDir = new File(FMLLaunchHandler.getMinecraftHome(), "settings");
+ private static File worldsDir = new File(FMLLaunchHandler.getMinecraftHome(), "worlds");
+
+ private static File serverConfigFile = new File(getSettingDir(), "server.yml");
+ private static File worldsConfigFile = new File(getSettingDir(), "worlds.yml");
+
+ private static UltramineServerConfig serverConfig;
+ private static WorldsConfig worldsConfig;
+
+ static
+ {
+ if(!settingsDir.exists()) settingsDir.mkdir();
+ if(!worldsDir.exists()) worldsDir.mkdir();
+ }
+
+ public static void load()
+ {
+ serverConfig = YamlConfigProvider.getOrCreateConfig(serverConfigFile, UltramineServerConfig.class);
+
+ if(!worldsConfigFile.exists())
+ YamlConfigProvider.writeFile(worldsConfigFile, Resources.getAsString("/org/ultramine/defaults/defaultworlds.yml")
+ .replace("{seed}", Long.toString(Math.abs(new Random().nextLong()))));
+ worldsConfig = YamlConfigProvider.readConfig(worldsConfigFile, WorldsConfig.class);
+ }
+
+ public static File getSettingDir()
+ {
+ return settingsDir;
+ }
+
+ public static File getWorldsDir()
+ {
+ return worldsDir;
+ }
+
+ public static UltramineServerConfig getServerConfig()
+ {
+ return serverConfig;
+ }
+
+ public static WorldsConfig getWorldsConfig()
+ {
+ return worldsConfig;
+ }
+
+ public static void saveServerConfig()
+ {
+ YamlConfigProvider.saveConfig(serverConfigFile, serverConfig);
+ }
+}
diff --git a/src/main/java/org/ultramine/server/MultiWorld.java b/src/main/java/org/ultramine/server/MultiWorld.java
index 9bceef1..77e113d 100644
--- a/src/main/java/org/ultramine/server/MultiWorld.java
+++ b/src/main/java/org/ultramine/server/MultiWorld.java
@@ -1,256 +1,256 @@
-package org.ultramine.server;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.ultramine.server.WorldsConfig.WorldConfig;
-import org.ultramine.server.WorldsConfig.WorldConfig.Settings.WorldTime;
-import org.ultramine.server.util.BasicTypeParser;
-
-import cpw.mods.fml.common.FMLCommonHandler;
-import cpw.mods.fml.common.eventhandler.SubscribeEvent;
-import cpw.mods.fml.common.network.FMLEmbeddedChannel;
-import cpw.mods.fml.common.network.FMLNetworkEvent;
-import cpw.mods.fml.common.network.FMLOutboundHandler;
-import cpw.mods.fml.common.network.NetworkRegistry;
-import cpw.mods.fml.common.network.handshake.NetworkDispatcher;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import gnu.trove.map.TIntObjectMap;
-import gnu.trove.map.hash.TIntObjectHashMap;
-import net.minecraft.server.MinecraftServer;
-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.AnvilSaveHandler;
-import net.minecraft.world.storage.ISaveFormat;
-import net.minecraft.world.storage.ISaveHandler;
-import net.minecraft.world.storage.WorldInfo;
-import net.minecraftforge.common.DimensionManager;
-import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.common.network.ForgeMessage;
-import net.minecraftforge.event.world.WorldEvent;
-
-public class MultiWorld
-{
- private static final Logger log = LogManager.getLogger();
- private final TIntObjectHashMap dimToNameMap = new TIntObjectHashMap();
- private final TIntObjectMap dimToWorldMap = new TIntObjectHashMap();
- private final Map nameToWorldMap = new HashMap();
- private final MinecraftServer server;
-
- public MultiWorld(MinecraftServer server)
- {
- this.server = server;
- }
-
- @SubscribeEvent
- public void onPlayerLoggedIn(FMLNetworkEvent.ServerConnectionFromClientEvent event)
- {
- FMLEmbeddedChannel channel = NetworkRegistry.INSTANCE.getChannel("FORGE", Side.SERVER);
- channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DISPATCHER);
- channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(event.manager.channel().attr(NetworkDispatcher.FML_DISPATCHER).get());
- for (int dim : DimensionManager.getStaticDimensionIDs())
- {
- int pid = DimensionManager.getProviderType(dim);
- channel.writeAndFlush(new ForgeMessage.DimensionRegisterMessage(dim, pid == -10 ? 0 : pid));
- }
- }
-
- @SubscribeEvent
- public void onWorldUnload(WorldEvent.Unload event)
- {
- dimToWorldMap.remove(event.world.provider.dimensionId);
- nameToWorldMap.remove(event.world.getWorldInfo().getWorldName());
- }
-
- @SideOnly(Side.SERVER)
- public void handleServerWorldsInit()
- {
- DimensionManager.registerProviderType(-10, org.ultramine.server.wempty.WorldProviderEmpty.class, false);
- DimensionManager.unregisterDimension(-1);
- DimensionManager.unregisterDimension(0);
- DimensionManager.unregisterDimension(1);
-
- Map worlds = ConfigurationHandler.getWorldsConfig().worlds;
-
- for(Map.Entry ent : worlds.entrySet())
- {
- WorldConfig conf = ent.getValue();
- DimensionManager.registerDimension(conf.dimension, conf.generation.providerID);
-
- dimToNameMap.put(conf.dimension, ent.getKey());
- }
-
- String mainWorldName = dimToNameMap.get(0);
- if(mainWorldName == null)
- mainWorldName = "world";
-
- WorldConfig mainConf = worlds.get(mainWorldName);
- if(mainConf == null)
- mainConf = ConfigurationHandler.getWorldsConfig().global;
-
- ISaveFormat format = server.getActiveAnvilConverter();
- ISaveHandler mainSaveHandler = format.getSaveLoader(mainWorldName, true);
- WorldSettings mainSettings = makeSettings(mainSaveHandler, mainConf);
-
- WorldServer mainWorld = new WorldServer(server, mainSaveHandler, mainWorldName, mainConf.dimension, mainSettings, server.theProfiler);
-
- initWorld(mainWorld, mainConf);
-
- for (int dim : DimensionManager.getStaticDimensionIDs())
- {
- if(dim == mainConf.dimension) continue;
-
- String name = dimToNameMap.get(dim);
- WorldConfig conf = name == null ? null : worlds.get(name);
- WorldServer world;
-
- if(conf == null)
- {
- log.warn("World with dimension id:%d was loaded bypass worlds configuration. Using global config", dim);
- world = new WorldServerMulti(server, mainSaveHandler, mainWorldName, dim, mainSettings, mainWorld, server.theProfiler);
- }
- else
- {
- ISaveHandler save = format.getSaveLoader(name, false);
- ((AnvilSaveHandler)save).setSingleStorage();
- world = new WorldServer(server, save, name, dim, makeSettings(save, conf), server.theProfiler);
- }
-
- initWorld(world, conf);
- }
- }
-
- @SideOnly(Side.CLIENT)
- public void handleClientWorldsInit()
- {
- WorldConfig conf = new WorldConfig();
- conf.mobSpawn = new WorldConfig.MobSpawn();
- conf.settings = new WorldConfig.Settings();
- conf.chunkLoading = new WorldConfig.ChunkLoading();
- for(WorldServer world : server.worldServers)
- world.setConfig(conf);
- }
-
- @SideOnly(Side.SERVER)
- public void initDimension(int dim)
- {
- ISaveFormat format = server.getActiveAnvilConverter();
-
- String name = dimToNameMap.get(dim);
- WorldConfig conf = name == null ? null : ConfigurationHandler.getWorldsConfig().worlds.get(name);
- WorldServer world;
-
- if(conf == null)
- {
- log.warn("World with dimension id:%d was loaded bypass worlds configuration. Using global config", dim);
- WorldServer mainWorld = getWorldByID(0);
- ISaveHandler mainSaveHandler = mainWorld.getSaveHandler();
- WorldSettings mainSettings = new WorldSettings(mainWorld.getWorldInfo());
- world = new WorldServerMulti(server, mainSaveHandler, mainWorld.getWorldInfo().getWorldName(), dim, mainSettings, mainWorld, server.theProfiler);
- }
- else
- {
- ISaveHandler save = format.getSaveLoader(name, false);
- ((AnvilSaveHandler)save).setSingleStorage();
- world = new WorldServer(server, save, name, dim, makeSettings(save, conf), server.theProfiler);
- }
-
- initWorld(world, conf);
- }
-
- @SideOnly(Side.SERVER)
- private WorldSettings makeSettings(ISaveHandler save, WorldConfig conf)
- {
- WorldInfo mainWorldInfo = save.loadWorldInfo();
- WorldSettings mainSettings;
-
- if (mainWorldInfo == null)
- {
- mainSettings = new WorldSettings(toSeed(conf.generation.seed), server.getGameType(), conf.generation.generateStructures,
- server.isHardcore(), WorldType.parseWorldType(conf.generation.levelType));
- mainSettings.func_82750_a(conf.generation.generatorSettings);
- }
- else
- {
- mainSettings = new WorldSettings(mainWorldInfo);
- }
-
- return mainSettings;
- }
-
- private static long toSeed(String seedstr)
- {
- try
- {
- return Long.parseLong(seedstr);
- }
- catch (NumberFormatException e)
- {
- return seedstr.hashCode();
- }
- }
-
- @SideOnly(Side.SERVER)
- private void initWorld(WorldServer world, WorldConfig conf)
- {
- world.addWorldAccess(new WorldManager(server, world));
-
- if (!server.isSinglePlayer())
- world.getWorldInfo().setGameType(server.getGameType());
-
- world.difficultySetting = BasicTypeParser.parseDifficulty(ConfigurationHandler.getWorldsConfig().global.settings.difficulty);
- world.setAllowedSpawnTypes(conf.mobSpawn.spawnMonsters, conf.mobSpawn.spawnAnimals);
- world.getGameRules().setOrCreateGameRule("doDaylightCycle", Boolean.toString(conf.settings.time != WorldTime.FIXED));
- world.setConfig(conf);
-
- MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world));
-
- String name = world.getWorldInfo().getWorldName();
- dimToWorldMap.put(world.provider.dimensionId, world);
- if(nameToWorldMap.containsKey(name))
- nameToWorldMap.put(name + world.provider.dimensionId, world);
- else
- nameToWorldMap.put(name, world);
- }
-
- public WorldServer getWorldByID(int dim)
- {
- return dimToWorldMap.get(dim);
- }
-
- public WorldServer getWorldByName(String name)
- {
- return nameToWorldMap.get(name);
- }
-
- public WorldServer getWorldByNameOrID(String id)
- {
- return BasicTypeParser.isInt(id) ? dimToWorldMap.get(Integer.parseInt(id)) : nameToWorldMap.get(id);
- }
-
- public Set getAllNames()
- {
- return nameToWorldMap.keySet();
- }
-
- public void register()
- {
- FMLCommonHandler.instance().bus().register(this);
- MinecraftForge.EVENT_BUS.register(this);
- }
-
- public void unregister()
- {
- FMLCommonHandler.instance().bus().unregister(this);
- MinecraftForge.EVENT_BUS.unregister(this);
- dimToWorldMap.clear();
- nameToWorldMap.clear();
- }
-}
+package org.ultramine.server;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.ultramine.server.WorldsConfig.WorldConfig;
+import org.ultramine.server.WorldsConfig.WorldConfig.Settings.WorldTime;
+import org.ultramine.server.util.BasicTypeParser;
+
+import cpw.mods.fml.common.FMLCommonHandler;
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import cpw.mods.fml.common.network.FMLEmbeddedChannel;
+import cpw.mods.fml.common.network.FMLNetworkEvent;
+import cpw.mods.fml.common.network.FMLOutboundHandler;
+import cpw.mods.fml.common.network.NetworkRegistry;
+import cpw.mods.fml.common.network.handshake.NetworkDispatcher;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gnu.trove.map.TIntObjectMap;
+import gnu.trove.map.hash.TIntObjectHashMap;
+import net.minecraft.server.MinecraftServer;
+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.AnvilSaveHandler;
+import net.minecraft.world.storage.ISaveFormat;
+import net.minecraft.world.storage.ISaveHandler;
+import net.minecraft.world.storage.WorldInfo;
+import net.minecraftforge.common.DimensionManager;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.common.network.ForgeMessage;
+import net.minecraftforge.event.world.WorldEvent;
+
+public class MultiWorld
+{
+ private static final Logger log = LogManager.getLogger();
+ private final TIntObjectHashMap dimToNameMap = new TIntObjectHashMap();
+ private final TIntObjectMap dimToWorldMap = new TIntObjectHashMap();
+ private final Map nameToWorldMap = new HashMap();
+ private final MinecraftServer server;
+
+ public MultiWorld(MinecraftServer server)
+ {
+ this.server = server;
+ }
+
+ @SubscribeEvent
+ public void onPlayerLoggedIn(FMLNetworkEvent.ServerConnectionFromClientEvent event)
+ {
+ FMLEmbeddedChannel channel = NetworkRegistry.INSTANCE.getChannel("FORGE", Side.SERVER);
+ channel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DISPATCHER);
+ channel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(event.manager.channel().attr(NetworkDispatcher.FML_DISPATCHER).get());
+ for (int dim : DimensionManager.getStaticDimensionIDs())
+ {
+ int pid = DimensionManager.getProviderType(dim);
+ channel.writeAndFlush(new ForgeMessage.DimensionRegisterMessage(dim, pid == -10 ? 0 : pid));
+ }
+ }
+
+ @SubscribeEvent
+ public void onWorldUnload(WorldEvent.Unload event)
+ {
+ dimToWorldMap.remove(event.world.provider.dimensionId);
+ nameToWorldMap.remove(event.world.getWorldInfo().getWorldName());
+ }
+
+ @SideOnly(Side.SERVER)
+ public void handleServerWorldsInit()
+ {
+ DimensionManager.registerProviderType(-10, org.ultramine.server.wempty.WorldProviderEmpty.class, false);
+ DimensionManager.unregisterDimension(-1);
+ DimensionManager.unregisterDimension(0);
+ DimensionManager.unregisterDimension(1);
+
+ Map worlds = ConfigurationHandler.getWorldsConfig().worlds;
+
+ for(Map.Entry ent : worlds.entrySet())
+ {
+ WorldConfig conf = ent.getValue();
+ DimensionManager.registerDimension(conf.dimension, conf.generation.providerID);
+
+ dimToNameMap.put(conf.dimension, ent.getKey());
+ }
+
+ String mainWorldName = dimToNameMap.get(0);
+ if(mainWorldName == null)
+ mainWorldName = "world";
+
+ WorldConfig mainConf = worlds.get(mainWorldName);
+ if(mainConf == null)
+ mainConf = ConfigurationHandler.getWorldsConfig().global;
+
+ ISaveFormat format = server.getActiveAnvilConverter();
+ ISaveHandler mainSaveHandler = format.getSaveLoader(mainWorldName, true);
+ WorldSettings mainSettings = makeSettings(mainSaveHandler, mainConf);
+
+ WorldServer mainWorld = new WorldServer(server, mainSaveHandler, mainWorldName, mainConf.dimension, mainSettings, server.theProfiler);
+
+ initWorld(mainWorld, mainConf);
+
+ for (int dim : DimensionManager.getStaticDimensionIDs())
+ {
+ if(dim == mainConf.dimension) continue;
+
+ String name = dimToNameMap.get(dim);
+ WorldConfig conf = name == null ? null : worlds.get(name);
+ WorldServer world;
+
+ if(conf == null)
+ {
+ log.warn("World with dimension id:%d was loaded bypass worlds configuration. Using global config", dim);
+ world = new WorldServerMulti(server, mainSaveHandler, mainWorldName, dim, mainSettings, mainWorld, server.theProfiler);
+ }
+ else
+ {
+ ISaveHandler save = format.getSaveLoader(name, false);
+ ((AnvilSaveHandler)save).setSingleStorage();
+ world = new WorldServer(server, save, name, dim, makeSettings(save, conf), server.theProfiler);
+ }
+
+ initWorld(world, conf);
+ }
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void handleClientWorldsInit()
+ {
+ WorldConfig conf = new WorldConfig();
+ conf.mobSpawn = new WorldConfig.MobSpawn();
+ conf.settings = new WorldConfig.Settings();
+ conf.chunkLoading = new WorldConfig.ChunkLoading();
+ for(WorldServer world : server.worldServers)
+ world.setConfig(conf);
+ }
+
+ @SideOnly(Side.SERVER)
+ public void initDimension(int dim)
+ {
+ ISaveFormat format = server.getActiveAnvilConverter();
+
+ String name = dimToNameMap.get(dim);
+ WorldConfig conf = name == null ? null : ConfigurationHandler.getWorldsConfig().worlds.get(name);
+ WorldServer world;
+
+ if(conf == null)
+ {
+ log.warn("World with dimension id:%d was loaded bypass worlds configuration. Using global config", dim);
+ WorldServer mainWorld = getWorldByID(0);
+ ISaveHandler mainSaveHandler = mainWorld.getSaveHandler();
+ WorldSettings mainSettings = new WorldSettings(mainWorld.getWorldInfo());
+ world = new WorldServerMulti(server, mainSaveHandler, mainWorld.getWorldInfo().getWorldName(), dim, mainSettings, mainWorld, server.theProfiler);
+ }
+ else
+ {
+ ISaveHandler save = format.getSaveLoader(name, false);
+ ((AnvilSaveHandler)save).setSingleStorage();
+ world = new WorldServer(server, save, name, dim, makeSettings(save, conf), server.theProfiler);
+ }
+
+ initWorld(world, conf);
+ }
+
+ @SideOnly(Side.SERVER)
+ private WorldSettings makeSettings(ISaveHandler save, WorldConfig conf)
+ {
+ WorldInfo mainWorldInfo = save.loadWorldInfo();
+ WorldSettings mainSettings;
+
+ if (mainWorldInfo == null)
+ {
+ mainSettings = new WorldSettings(toSeed(conf.generation.seed), server.getGameType(), conf.generation.generateStructures,
+ server.isHardcore(), WorldType.parseWorldType(conf.generation.levelType));
+ mainSettings.func_82750_a(conf.generation.generatorSettings);
+ }
+ else
+ {
+ mainSettings = new WorldSettings(mainWorldInfo);
+ }
+
+ return mainSettings;
+ }
+
+ private static long toSeed(String seedstr)
+ {
+ try
+ {
+ return Long.parseLong(seedstr);
+ }
+ catch (NumberFormatException e)
+ {
+ return seedstr.hashCode();
+ }
+ }
+
+ @SideOnly(Side.SERVER)
+ private void initWorld(WorldServer world, WorldConfig conf)
+ {
+ world.addWorldAccess(new WorldManager(server, world));
+
+ if (!server.isSinglePlayer())
+ world.getWorldInfo().setGameType(server.getGameType());
+
+ world.difficultySetting = BasicTypeParser.parseDifficulty(ConfigurationHandler.getWorldsConfig().global.settings.difficulty);
+ world.setAllowedSpawnTypes(conf.mobSpawn.spawnMonsters, conf.mobSpawn.spawnAnimals);
+ world.getGameRules().setOrCreateGameRule("doDaylightCycle", Boolean.toString(conf.settings.time != WorldTime.FIXED));
+ world.setConfig(conf);
+
+ MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world));
+
+ String name = world.getWorldInfo().getWorldName();
+ dimToWorldMap.put(world.provider.dimensionId, world);
+ if(nameToWorldMap.containsKey(name))
+ nameToWorldMap.put(name + world.provider.dimensionId, world);
+ else
+ nameToWorldMap.put(name, world);
+ }
+
+ public WorldServer getWorldByID(int dim)
+ {
+ return dimToWorldMap.get(dim);
+ }
+
+ public WorldServer getWorldByName(String name)
+ {
+ return nameToWorldMap.get(name);
+ }
+
+ public WorldServer getWorldByNameOrID(String id)
+ {
+ return BasicTypeParser.isInt(id) ? dimToWorldMap.get(Integer.parseInt(id)) : nameToWorldMap.get(id);
+ }
+
+ public Set getAllNames()
+ {
+ return nameToWorldMap.keySet();
+ }
+
+ public void register()
+ {
+ FMLCommonHandler.instance().bus().register(this);
+ MinecraftForge.EVENT_BUS.register(this);
+ }
+
+ public void unregister()
+ {
+ FMLCommonHandler.instance().bus().unregister(this);
+ MinecraftForge.EVENT_BUS.unregister(this);
+ dimToWorldMap.clear();
+ nameToWorldMap.clear();
+ }
+}
diff --git a/src/main/java/org/ultramine/server/Teleporter.java b/src/main/java/org/ultramine/server/Teleporter.java
index 040466e..fa12e5e 100644
--- a/src/main/java/org/ultramine/server/Teleporter.java
+++ b/src/main/java/org/ultramine/server/Teleporter.java
@@ -1,47 +1,47 @@
-package org.ultramine.server;
-
-import org.ultramine.server.util.WarpLocation;
-
-import net.minecraft.entity.player.EntityPlayerMP;
-
-public class Teleporter
-{
- public static void tpNow(EntityPlayerMP target, EntityPlayerMP dst)
- {
- if(target == null || dst == null) return;
- doTeleportation(target, dst.worldObj.provider.dimensionId, dst.posX, dst.posY, dst.posZ, dst.rotationYaw, dst.rotationPitch);
- }
-
- public static void tpNow(EntityPlayerMP target, double x, double y, double z)
- {
- if(target == null) return;
- doTeleportation(target, target.worldObj.provider.dimensionId, x, y, z, target.rotationYaw, target.rotationPitch);
- }
-
- public static void tpNow(EntityPlayerMP target, int dimension, double x, double y, double z)
- {
- if(target == null) return;
- doTeleportation(target, dimension, x, y, z, target.rotationYaw, target.rotationPitch);
- }
-
- public static void tpNow(EntityPlayerMP target, WarpLocation dst)
- {
- if(target == null || dst == null) return;
- doTeleportation(target, dst.dimension, dst.x, dst.y, dst.z, dst.yaw, dst.pitch);
- }
-
- private static void doTeleportation(EntityPlayerMP player, int dimension, double x, double y, double z, float yaw, float pitch)
- {
- //player.getPlayerData().lastLocation = WarpLocation.getFromPlayer(player);
-
- player.playerNetServerHandler.setPlayerLocation(x, y, z, yaw, pitch);
-
- if(player.dimension != dimension)
- {
- player.transferToDimension(dimension);
- }
-
- //player.getPlayerData().onTeleport();
- //player.getPlayerData().teleport = null;
- }
-}
+package org.ultramine.server;
+
+import org.ultramine.server.util.WarpLocation;
+
+import net.minecraft.entity.player.EntityPlayerMP;
+
+public class Teleporter
+{
+ public static void tpNow(EntityPlayerMP target, EntityPlayerMP dst)
+ {
+ if(target == null || dst == null) return;
+ doTeleportation(target, dst.worldObj.provider.dimensionId, dst.posX, dst.posY, dst.posZ, dst.rotationYaw, dst.rotationPitch);
+ }
+
+ public static void tpNow(EntityPlayerMP target, double x, double y, double z)
+ {
+ if(target == null) return;
+ doTeleportation(target, target.worldObj.provider.dimensionId, x, y, z, target.rotationYaw, target.rotationPitch);
+ }
+
+ public static void tpNow(EntityPlayerMP target, int dimension, double x, double y, double z)
+ {
+ if(target == null) return;
+ doTeleportation(target, dimension, x, y, z, target.rotationYaw, target.rotationPitch);
+ }
+
+ public static void tpNow(EntityPlayerMP target, WarpLocation dst)
+ {
+ if(target == null || dst == null) return;
+ doTeleportation(target, dst.dimension, dst.x, dst.y, dst.z, dst.yaw, dst.pitch);
+ }
+
+ private static void doTeleportation(EntityPlayerMP player, int dimension, double x, double y, double z, float yaw, float pitch)
+ {
+ //player.getPlayerData().lastLocation = WarpLocation.getFromPlayer(player);
+
+ player.playerNetServerHandler.setPlayerLocation(x, y, z, yaw, pitch);
+
+ if(player.dimension != dimension)
+ {
+ player.transferToDimension(dimension);
+ }
+
+ //player.getPlayerData().onTeleport();
+ //player.getPlayerData().teleport = null;
+ }
+}
diff --git a/src/main/java/org/ultramine/server/UMEventHandler.java b/src/main/java/org/ultramine/server/UMEventHandler.java
index e61dde8..b188ed6 100644
--- a/src/main/java/org/ultramine/server/UMEventHandler.java
+++ b/src/main/java/org/ultramine/server/UMEventHandler.java
@@ -1,44 +1,44 @@
-package org.ultramine.server;
-
-import cpw.mods.fml.common.eventhandler.SubscribeEvent;
-import net.minecraft.util.ChatComponentStyle;
-import net.minecraft.util.ChatComponentText;
-import net.minecraft.util.ChatComponentTranslation;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraftforge.event.ServerChatEvent;
-
-public class UMEventHandler
-{
- @SubscribeEvent
- public void onServerChat(ServerChatEvent e)
- {
- String prefix = PermissionHandler.getInstance().getMeta(e.player, "prefix").replace('&', '\u00A7');
- String postfix = PermissionHandler.getInstance().getMeta(e.player, "postfix").replace('&', '\u00A7');
-
- String namecolor = PermissionHandler.getInstance().getMeta(e.player, "color");
- String msgcolor = PermissionHandler.getInstance().getMeta(e.player, "textcolor");
-
- ChatComponentStyle username = (ChatComponentStyle) e.player.func_145748_c_();
- ChatComponentStyle msg = new ChatComponentText(e.message);
-
- if(!namecolor.isEmpty())
- {
- EnumChatFormatting color = EnumChatFormatting.getByColorCode(namecolor.charAt(0));
- if(color != null)
- username.getChatStyle().setColor(color);
- }
-
- if(!msgcolor.isEmpty())
- {
- EnumChatFormatting color = EnumChatFormatting.getByColorCode(msgcolor.charAt(0));
- if(color != null)
- msg.getChatStyle().setColor(color);
- }
- else
- {
- msg.getChatStyle().setColor(EnumChatFormatting.WHITE);
- }
-
- e.component = new ChatComponentTranslation("%s%s%s\u00A77: %s", prefix, username, postfix, msg);
- }
-}
+package org.ultramine.server;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import net.minecraft.util.ChatComponentStyle;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.ChatComponentTranslation;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraftforge.event.ServerChatEvent;
+
+public class UMEventHandler
+{
+ @SubscribeEvent
+ public void onServerChat(ServerChatEvent e)
+ {
+ String prefix = PermissionHandler.getInstance().getMeta(e.player, "prefix").replace('&', '\u00A7');
+ String postfix = PermissionHandler.getInstance().getMeta(e.player, "postfix").replace('&', '\u00A7');
+
+ String namecolor = PermissionHandler.getInstance().getMeta(e.player, "color");
+ String msgcolor = PermissionHandler.getInstance().getMeta(e.player, "textcolor");
+
+ ChatComponentStyle username = (ChatComponentStyle) e.player.func_145748_c_();
+ ChatComponentStyle msg = new ChatComponentText(e.message);
+
+ if(!namecolor.isEmpty())
+ {
+ EnumChatFormatting color = EnumChatFormatting.getByColorCode(namecolor.charAt(0));
+ if(color != null)
+ username.getChatStyle().setColor(color);
+ }
+
+ if(!msgcolor.isEmpty())
+ {
+ EnumChatFormatting color = EnumChatFormatting.getByColorCode(msgcolor.charAt(0));
+ if(color != null)
+ msg.getChatStyle().setColor(color);
+ }
+ else
+ {
+ msg.getChatStyle().setColor(EnumChatFormatting.WHITE);
+ }
+
+ e.component = new ChatComponentTranslation("%s%s%s\u00A77: %s", prefix, username, postfix, msg);
+ }
+}
diff --git a/src/main/java/org/ultramine/server/UltramineServerConfig.java b/src/main/java/org/ultramine/server/UltramineServerConfig.java
index 785f9cf..ce50893 100644
--- a/src/main/java/org/ultramine/server/UltramineServerConfig.java
+++ b/src/main/java/org/ultramine/server/UltramineServerConfig.java
@@ -1,44 +1,44 @@
-package org.ultramine.server;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-public class UltramineServerConfig
-{
- public WatchdogThreadConfig watchdogThread = new WatchdogThreadConfig();
- public VanillaConfig vanilla = new VanillaConfig();
-
- public static class WatchdogThreadConfig
- {
- public int timeout = 120;
- public boolean restart = true;
- }
-
-
-
- public static class VanillaConfig
- {
- public boolean enableQuery = false;
- public int queryPort = 25565;
- public boolean allowFlight = false;
- public boolean announcePlayerAchievements = true;
- public int serverPort = 25565;
- public boolean enableRcon = false;
- public int rconPort = 0;
- public String rconPassword = "";
- public boolean forceGamemode = false;
- public String serverIp = "";
- public boolean whiteList = false;
- public boolean snooperEnabled = true;
- public boolean hardcore = false;
- public boolean onlineMode = true;
- public String resourcePack = "";
- public boolean enableCommandBlock = false;
- public int playerIdleTimeout = 0;
- public int gamemode = 0;
- public int maxPlayers = 20;
- public String motd = "A Minecraft Server";
-
- public Map unresolved = new LinkedHashMap();
- }
-}
+package org.ultramine.server;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class UltramineServerConfig
+{
+ public WatchdogThreadConfig watchdogThread = new WatchdogThreadConfig();
+ public VanillaConfig vanilla = new VanillaConfig();
+
+ public static class WatchdogThreadConfig
+ {
+ public int timeout = 120;
+ public boolean restart = true;
+ }
+
+
+
+ public static class VanillaConfig
+ {
+ public boolean enableQuery = false;
+ public int queryPort = 25565;
+ public boolean allowFlight = false;
+ public boolean announcePlayerAchievements = true;
+ public int serverPort = 25565;
+ public boolean enableRcon = false;
+ public int rconPort = 0;
+ public String rconPassword = "";
+ public boolean forceGamemode = false;
+ public String serverIp = "";
+ public boolean whiteList = false;
+ public boolean snooperEnabled = true;
+ public boolean hardcore = false;
+ public boolean onlineMode = true;
+ public String resourcePack = "";
+ public boolean enableCommandBlock = false;
+ public int playerIdleTimeout = 0;
+ public int gamemode = 0;
+ public int maxPlayers = 20;
+ public String motd = "A Minecraft Server";
+
+ public Map unresolved = new LinkedHashMap();
+ }
+}
diff --git a/src/main/java/org/ultramine/server/UltramineServerModContainer.java b/src/main/java/org/ultramine/server/UltramineServerModContainer.java
index c6eac33..64b18df 100644
--- a/src/main/java/org/ultramine/server/UltramineServerModContainer.java
+++ b/src/main/java/org/ultramine/server/UltramineServerModContainer.java
@@ -1,124 +1,124 @@
-package org.ultramine.server;
-
-import java.io.File;
-import java.util.List;
-import java.util.Map;
-
-import net.minecraft.server.MinecraftServer;
-import net.minecraftforge.common.MinecraftForge;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.eventbus.EventBus;
-import com.google.common.eventbus.Subscribe;
-
-import cpw.mods.fml.common.DummyModContainer;
-import cpw.mods.fml.common.LoadController;
-import cpw.mods.fml.common.ModMetadata;
-import cpw.mods.fml.common.event.FMLConstructionEvent;
-import cpw.mods.fml.common.event.FMLInitializationEvent;
-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.FMLServerStartingEvent;
-import cpw.mods.fml.common.event.FMLServerStoppedEvent;
-import cpw.mods.fml.common.network.NetworkCheckHandler;
-import cpw.mods.fml.common.network.NetworkRegistry;
-import cpw.mods.fml.relauncher.Side;
-
-import org.ultramine.commands.basic.VanillaCommands;
-import org.ultramine.commands.syntax.DefaultCompleters;
-import org.ultramine.permission.commands.BasicPermissionCommands;
-import org.ultramine.permission.internal.OpPermissionProxySet;
-
-public class UltramineServerModContainer extends DummyModContainer
-{
- public UltramineServerModContainer()
- {
- super(new ModMetadata());
- ModMetadata meta = getMetadata();
- meta.modId = "UltramineServer";
- meta.name = "Ultramine Server";
- meta.version = "1.0";
- }
-
- @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());
- }
-
- @Subscribe
- public void preInit(FMLPreInitializationEvent e)
- {
- if(e.getSide().isServer())
- ConfigurationHandler.load();
- }
-
- @Subscribe
- public void init(FMLInitializationEvent e)
- {
- MinecraftForge.EVENT_BUS.register(new UMEventHandler());
- }
-
- @Subscribe
- public void postInit(FMLPostInitializationEvent e)
- {
- if(e.getSide().isServer())
- ConfigurationHandler.saveServerConfig();
- }
-
- @Subscribe
- public void serverAboutToStart(FMLServerAboutToStartEvent e)
- {
- e.getServer().getMultiWorld().register();
- }
-
- @Subscribe
- public void serverStarting(FMLServerStartingEvent e)
- {
- e.registerArgumentHandlers(DefaultCompleters.class);
- e.registerCommands(BasicPermissionCommands.class);
- e.registerCommands(VanillaCommands.class);
-
- e.getPermissionHandler().createGroup(OpPermissionProxySet.OP_GROUP, "*");
- }
-
- @Subscribe
- public void serverStopped(FMLServerStoppedEvent e)
- {
- MinecraftServer.getServer().getMultiWorld().unregister();
- }
-
- @NetworkCheckHandler
- public boolean networkCheck(Map map, Side side)
- {
- return true;
- }
-
- @Override
- public File getSource()
- {
- return UltraminePlugin.location;
- }
-
- @Override
- public List getOwnedPackages()
- {
- return ImmutableList.of(
- "org.ultramine.server"
- );
- }
-
- @Override
- public Object getMod()
- {
- return this;
- }
-}
+package org.ultramine.server;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+import net.minecraft.server.MinecraftServer;
+import net.minecraftforge.common.MinecraftForge;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.eventbus.EventBus;
+import com.google.common.eventbus.Subscribe;
+
+import cpw.mods.fml.common.DummyModContainer;
+import cpw.mods.fml.common.LoadController;
+import cpw.mods.fml.common.ModMetadata;
+import cpw.mods.fml.common.event.FMLConstructionEvent;
+import cpw.mods.fml.common.event.FMLInitializationEvent;
+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.FMLServerStartingEvent;
+import cpw.mods.fml.common.event.FMLServerStoppedEvent;
+import cpw.mods.fml.common.network.NetworkCheckHandler;
+import cpw.mods.fml.common.network.NetworkRegistry;
+import cpw.mods.fml.relauncher.Side;
+
+import org.ultramine.commands.basic.VanillaCommands;
+import org.ultramine.commands.syntax.DefaultCompleters;
+import org.ultramine.permission.commands.BasicPermissionCommands;
+import org.ultramine.permission.internal.OpPermissionProxySet;
+
+public class UltramineServerModContainer extends DummyModContainer
+{
+ public UltramineServerModContainer()
+ {
+ super(new ModMetadata());
+ ModMetadata meta = getMetadata();
+ meta.modId = "UltramineServer";
+ meta.name = "Ultramine Server";
+ meta.version = "1.0";
+ }
+
+ @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());
+ }
+
+ @Subscribe
+ public void preInit(FMLPreInitializationEvent e)
+ {
+ if(e.getSide().isServer())
+ ConfigurationHandler.load();
+ }
+
+ @Subscribe
+ public void init(FMLInitializationEvent e)
+ {
+ MinecraftForge.EVENT_BUS.register(new UMEventHandler());
+ }
+
+ @Subscribe
+ public void postInit(FMLPostInitializationEvent e)
+ {
+ if(e.getSide().isServer())
+ ConfigurationHandler.saveServerConfig();
+ }
+
+ @Subscribe
+ public void serverAboutToStart(FMLServerAboutToStartEvent e)
+ {
+ e.getServer().getMultiWorld().register();
+ }
+
+ @Subscribe
+ public void serverStarting(FMLServerStartingEvent e)
+ {
+ e.registerArgumentHandlers(DefaultCompleters.class);
+ e.registerCommands(BasicPermissionCommands.class);
+ e.registerCommands(VanillaCommands.class);
+
+ e.getPermissionHandler().createGroup(OpPermissionProxySet.OP_GROUP, "*");
+ }
+
+ @Subscribe
+ public void serverStopped(FMLServerStoppedEvent e)
+ {
+ MinecraftServer.getServer().getMultiWorld().unregister();
+ }
+
+ @NetworkCheckHandler
+ public boolean networkCheck(Map map, Side side)
+ {
+ return true;
+ }
+
+ @Override
+ public File getSource()
+ {
+ return UltraminePlugin.location;
+ }
+
+ @Override
+ public List getOwnedPackages()
+ {
+ return ImmutableList.of(
+ "org.ultramine.server"
+ );
+ }
+
+ @Override
+ public Object getMod()
+ {
+ return this;
+ }
+}
diff --git a/src/main/java/org/ultramine/server/WatchdogThread.java b/src/main/java/org/ultramine/server/WatchdogThread.java
index 8cabd84..b4cd57b 100644
--- a/src/main/java/org/ultramine/server/WatchdogThread.java
+++ b/src/main/java/org/ultramine/server/WatchdogThread.java
@@ -1,122 +1,122 @@
-package org.ultramine.server;
-
-import java.lang.management.ManagementFactory;
-import java.lang.management.MonitorInfo;
-import java.lang.management.ThreadInfo;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-
-@SideOnly(Side.SERVER)
-public class WatchdogThread extends Thread
-{
- Logger log = LogManager.getLogger();
-
- private static WatchdogThread instance;
- private final long timeoutTime;
- private final boolean restart;
- private volatile long lastTick;
- private volatile boolean stopping;
-
- private WatchdogThread(long timeoutTime, boolean restart)
- {
- super("Spigot Watchdog Thread");
- this.timeoutTime = timeoutTime;
- this.restart = restart;
- }
-
- public static void doStart(int timeoutTime, boolean restart)
- {
- if(instance == null)
- {
- instance = new WatchdogThread(timeoutTime * 1000L, restart);
- instance.start();
- }
- }
-
- public static void doStart()
- {
- doStart(ConfigurationHandler.getServerConfig().watchdogThread.timeout, ConfigurationHandler.getServerConfig().watchdogThread.restart);
- }
-
- public static void tick()
- {
- instance.lastTick = System.currentTimeMillis();
- }
-
- public static void doStop()
- {
- if(instance != null)
- {
- instance.stopping = true;
- }
- }
-
- @Override
- public void run()
- {
- while(!stopping)
- {
- //
- if(lastTick != 0 && System.currentTimeMillis() > lastTick + timeoutTime)
- {
- log.log(Level.FATAL, "The server has stopped responding!");
-
- log.log(Level.FATAL, "Current Thread State:");
- ThreadInfo[] threads = ManagementFactory.getThreadMXBean().dumpAllThreads(true, true);
-
- for(ThreadInfo thread : threads)
- {
- if(thread.getThreadState() != State.WAITING)
- {
- log.log(Level.FATAL, "------------------------------");
- //
- log.log(Level.FATAL, "Current Thread: " + thread.getThreadName());
- log.log(Level.FATAL, "\tPID: " + thread.getThreadId() + " | Suspended: " + thread.isSuspended() + " | Native: " + thread.isInNative() + " | State: "
- + thread.getThreadState());
-
- if(thread.getLockedMonitors().length != 0)
- {
- log.log(Level.FATAL, "\tThread is waiting on monitor(s):");
-
- for(MonitorInfo monitor : thread.getLockedMonitors())
- {
- log.log(Level.FATAL, "\t\tLocked on:" + monitor.getLockedStackFrame());
- }
- }
-
- log.log(Level.FATAL, "\tStack:");
- //
- StackTraceElement[] stack = thread.getStackTrace();
-
- for(int line = 0; line < stack.length; line++)
- {
- log.log(Level.FATAL, "\t\t" + stack[line].toString());
- }
- }
- }
-
- log.log(Level.FATAL, "------------------------------");
-
- if(restart)
- {
- System.exit(0);
- }
-
- break;
- }
-
- try
- {
- sleep(10000);
- } catch (InterruptedException ex)
- {
- // interrupt();
- }
- }
- }
-}
+package org.ultramine.server;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.MonitorInfo;
+import java.lang.management.ThreadInfo;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+@SideOnly(Side.SERVER)
+public class WatchdogThread extends Thread
+{
+ Logger log = LogManager.getLogger();
+
+ private static WatchdogThread instance;
+ private final long timeoutTime;
+ private final boolean restart;
+ private volatile long lastTick;
+ private volatile boolean stopping;
+
+ private WatchdogThread(long timeoutTime, boolean restart)
+ {
+ super("Spigot Watchdog Thread");
+ this.timeoutTime = timeoutTime;
+ this.restart = restart;
+ }
+
+ public static void doStart(int timeoutTime, boolean restart)
+ {
+ if(instance == null)
+ {
+ instance = new WatchdogThread(timeoutTime * 1000L, restart);
+ instance.start();
+ }
+ }
+
+ public static void doStart()
+ {
+ doStart(ConfigurationHandler.getServerConfig().watchdogThread.timeout, ConfigurationHandler.getServerConfig().watchdogThread.restart);
+ }
+
+ public static void tick()
+ {
+ instance.lastTick = System.currentTimeMillis();
+ }
+
+ public static void doStop()
+ {
+ if(instance != null)
+ {
+ instance.stopping = true;
+ }
+ }
+
+ @Override
+ public void run()
+ {
+ while(!stopping)
+ {
+ //
+ if(lastTick != 0 && System.currentTimeMillis() > lastTick + timeoutTime)
+ {
+ log.log(Level.FATAL, "The server has stopped responding!");
+
+ log.log(Level.FATAL, "Current Thread State:");
+ ThreadInfo[] threads = ManagementFactory.getThreadMXBean().dumpAllThreads(true, true);
+
+ for(ThreadInfo thread : threads)
+ {
+ if(thread.getThreadState() != State.WAITING)
+ {
+ log.log(Level.FATAL, "------------------------------");
+ //
+ log.log(Level.FATAL, "Current Thread: " + thread.getThreadName());
+ log.log(Level.FATAL, "\tPID: " + thread.getThreadId() + " | Suspended: " + thread.isSuspended() + " | Native: " + thread.isInNative() + " | State: "
+ + thread.getThreadState());
+
+ if(thread.getLockedMonitors().length != 0)
+ {
+ log.log(Level.FATAL, "\tThread is waiting on monitor(s):");
+
+ for(MonitorInfo monitor : thread.getLockedMonitors())
+ {
+ log.log(Level.FATAL, "\t\tLocked on:" + monitor.getLockedStackFrame());
+ }
+ }
+
+ log.log(Level.FATAL, "\tStack:");
+ //
+ StackTraceElement[] stack = thread.getStackTrace();
+
+ for(int line = 0; line < stack.length; line++)
+ {
+ log.log(Level.FATAL, "\t\t" + stack[line].toString());
+ }
+ }
+ }
+
+ log.log(Level.FATAL, "------------------------------");
+
+ if(restart)
+ {
+ System.exit(0);
+ }
+
+ break;
+ }
+
+ try
+ {
+ sleep(10000);
+ } catch (InterruptedException ex)
+ {
+ // interrupt();
+ }
+ }
+ }
+}
diff --git a/src/main/java/org/ultramine/server/WorldsConfig.java b/src/main/java/org/ultramine/server/WorldsConfig.java
index 6345771..cf0b829 100644
--- a/src/main/java/org/ultramine/server/WorldsConfig.java
+++ b/src/main/java/org/ultramine/server/WorldsConfig.java
@@ -1,62 +1,62 @@
-package org.ultramine.server;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class WorldsConfig
-{
- public WorldConfig global = new WorldConfig();
- public Map worlds = new HashMap();
-
- public static class WorldConfig
- {
- public int dimension;
- public Generation generation;
- public MobSpawn mobSpawn;
- public Settings settings;
- public ChunkLoading chunkLoading;
-
- public static class Generation
- {
- public String seed;
- public int providerID = 0;
- public String levelType = "DEFAULT";
- public String generatorSettings = "";
- public boolean generateStructures = true;
- }
-
- public static class MobSpawn
- {
- public boolean spawnAnimals = true;
- public boolean spawnMonsters = true;
- public boolean spawnNPCs = true;
- }
-
- public static class Settings
- {
- public String difficulty = "1";
- public boolean pvp = true;
- public int maxBuildHeight = 256;
- public WorldTime time = WorldTime.NORMAL;
- public Weather weather = Weather.NORMAL;
-
- public enum WorldTime
- {
- NORMAL, DAY, NIGHT, FIXED
- }
-
- public enum Weather
- {
- NORMAL, NONE, RAIN, THUNDER
- }
- }
-
- public static class ChunkLoading
- {
- public int viewDistance = 10;
- public int chunkUpdateRadius = 7;
- public int chunkCacheSize;
- public boolean enableChunkLoaders = true;
- }
- }
-}
+package org.ultramine.server;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class WorldsConfig
+{
+ public WorldConfig global = new WorldConfig();
+ public Map worlds = new HashMap();
+
+ public static class WorldConfig
+ {
+ public int dimension;
+ public Generation generation;
+ public MobSpawn mobSpawn;
+ public Settings settings;
+ public ChunkLoading chunkLoading;
+
+ public static class Generation
+ {
+ public String seed;
+ public int providerID = 0;
+ public String levelType = "DEFAULT";
+ public String generatorSettings = "";
+ public boolean generateStructures = true;
+ }
+
+ public static class MobSpawn
+ {
+ public boolean spawnAnimals = true;
+ public boolean spawnMonsters = true;
+ public boolean spawnNPCs = true;
+ }
+
+ public static class Settings
+ {
+ public String difficulty = "1";
+ public boolean pvp = true;
+ public int maxBuildHeight = 256;
+ public WorldTime time = WorldTime.NORMAL;
+ public Weather weather = Weather.NORMAL;
+
+ public enum WorldTime
+ {
+ NORMAL, DAY, NIGHT, FIXED
+ }
+
+ public enum Weather
+ {
+ NORMAL, NONE, RAIN, THUNDER
+ }
+ }
+
+ public static class ChunkLoading
+ {
+ public int viewDistance = 10;
+ public int chunkUpdateRadius = 7;
+ public int chunkCacheSize;
+ public boolean enableChunkLoaders = true;
+ }
+ }
+}
diff --git a/src/main/java/org/ultramine/server/chunk/ChunkBindState.java b/src/main/java/org/ultramine/server/chunk/ChunkBindState.java
index 780b086..24cc6f5 100644
--- a/src/main/java/org/ultramine/server/chunk/ChunkBindState.java
+++ b/src/main/java/org/ultramine/server/chunk/ChunkBindState.java
@@ -1,49 +1,49 @@
-package org.ultramine.server.chunk;
-
-public enum ChunkBindState
-{
- /**
- * Чанк ничем не занят и может быть выгружен в любой момент. Стандартное
- * значение при асинхронной загрузке чанка.
- */
- NONE,
- /**
- * Чанк занят игроком/игроками. Как только все игроки выйдут из радиуса
- * прогрузки, значение сменится на NONE
.
- */
- PLAYER,
- /**
- * Чанк был загружен синхронно, в обход менеджера загрузки чанков. По логике
- * ванильного майна это является утечкой памяти - чанк не будет выгружен из
- * памяти до тех пор, пока не будет помечен к отгрузке вручную (например, в
- * него зайдет и выйдет игрок). Но у нас чанк будет выгружен через некоторое
- * время.
- */
- LEAK,
- /**
- * Чанк обнаружен в списке PersistentChunks, созданного форжей для всяких
- * чанклоадеров. Не будет выгружен до тех пор, пока не исчезнет из этого
- * списка.
- */
- FORGE,
- /**
- * Чанку запрещено выгружаться или изменять состояние бинда. Чанк не будет
- * выгружен никогда.
- */
- ETERNAL;
-
- public boolean canUnload()
- {
- return this == NONE;
- }
-
- public boolean canChangeState()
- {
- return this != ETERNAL && this != FORGE;
- }
-
- public boolean isLeak()
- {
- return this == LEAK || this == FORGE;
- }
-}
+package org.ultramine.server.chunk;
+
+public enum ChunkBindState
+{
+ /**
+ * Чанк ничем не занят и может быть выгружен в любой момент. Стандартное
+ * значение при асинхронной загрузке чанка.
+ */
+ NONE,
+ /**
+ * Чанк занят игроком/игроками. Как только все игроки выйдут из радиуса
+ * прогрузки, значение сменится на NONE
.
+ */
+ PLAYER,
+ /**
+ * Чанк был загружен синхронно, в обход менеджера загрузки чанков. По логике
+ * ванильного майна это является утечкой памяти - чанк не будет выгружен из
+ * памяти до тех пор, пока не будет помечен к отгрузке вручную (например, в
+ * него зайдет и выйдет игрок). Но у нас чанк будет выгружен через некоторое
+ * время.
+ */
+ LEAK,
+ /**
+ * Чанк обнаружен в списке PersistentChunks, созданного форжей для всяких
+ * чанклоадеров. Не будет выгружен до тех пор, пока не исчезнет из этого
+ * списка.
+ */
+ FORGE,
+ /**
+ * Чанку запрещено выгружаться или изменять состояние бинда. Чанк не будет
+ * выгружен никогда.
+ */
+ ETERNAL;
+
+ public boolean canUnload()
+ {
+ return this == NONE;
+ }
+
+ public boolean canChangeState()
+ {
+ return this != ETERNAL && this != FORGE;
+ }
+
+ public boolean isLeak()
+ {
+ return this == LEAK || this == FORGE;
+ }
+}
diff --git a/src/main/java/org/ultramine/server/chunk/ChunkGC.java b/src/main/java/org/ultramine/server/chunk/ChunkGC.java
index 4ff232f..9ed48f1 100644
--- a/src/main/java/org/ultramine/server/chunk/ChunkGC.java
+++ b/src/main/java/org/ultramine/server/chunk/ChunkGC.java
@@ -1,124 +1,124 @@
-package org.ultramine.server.chunk;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Set;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import net.minecraft.world.ChunkCoordIntPair;
-import net.minecraft.world.WorldServer;
-import net.minecraft.world.chunk.Chunk;
-import net.minecraft.world.gen.ChunkProviderServer;
-
-@SideOnly(Side.SERVER)
-public class ChunkGC
-{
- private static final int MIN_GC_INTERVAL = 100;
- private static final int MAX_UNLOAD_QUEUE_SIZE = 128;
- private static final int MAX_CHUNKS_PER_OP = 1024;
- private static final int _10_MINUTES = 20*60*10;
-
- private final ChunkProviderServer provider;
- private final WorldServer world;
-
- private int lastGCTime;
- private int lastChunkCount;
- private int minChunkDiff;
-
- public ChunkGC(ChunkProviderServer provider)
- {
- this.provider = provider;
- this.world = provider.worldObj;
- }
-
- public void onTick()
- {
- int confCacheSize = world.getConfig().chunkLoading.chunkCacheSize;
- int chunksPerPlayer = (int)Math.pow(world.getConfig().chunkLoading.viewDistance*2 + 1, 2);
- int boundChunks = world.playerEntities.size()*chunksPerPlayer + world.getPersistentChunks().size();
- int chunkLimit = boundChunks + confCacheSize + MAX_CHUNKS_PER_OP;
-
- int curTime = world.func_73046_m().getTickCounter();
- int unloadQueueSize = provider.chunksToUnload.size();
- int chunkCount = provider.loadedChunkHashMap.size() - unloadQueueSize;
- int timePassed = curTime - lastGCTime;
- int chunkDiff = chunkCount - lastChunkCount;
-
- if(chunkCount > chunkLimit && timePassed > MIN_GC_INTERVAL && unloadQueueSize < MAX_UNLOAD_QUEUE_SIZE && (minChunkDiff == 0 || chunkDiff > minChunkDiff))
- {
- Set persistentChunks = world.getPersistentChunks().keySet();
- Collection all = provider.loadedChunkHashMap.valueCollection();
- List unbound = new ArrayList(all.size() - boundChunks);
- for(Chunk chunk : all)
- {
- ChunkBindState state = chunk.getBindState();
- if(state.canUnload())
- {
- unbound.add(chunk);
- }
- else if(state.isLeak() && curTime - chunk.getUnbindTime() > _10_MINUTES)
- {
- if(persistentChunks.contains(chunk.getChunkCoordIntPair()))
- {
- if(state != ChunkBindState.FORGE)
- chunk.setBindState(ChunkBindState.FORGE);
- chunk.updateUnbindTime();
- }
- else
- {
- chunk.unbind();
- unbound.add(chunk);
- }
- }
- }
-
- int unboundLimit = confCacheSize + MAX_CHUNKS_PER_OP + unloadQueueSize;
-
- if(unbound.size() > unboundLimit)
- {
- //performing GC
- Collections.sort(unbound, new ChunkComparator(curTime));
-
- for(int i = 0, s = Math.min(unbound.size(), MAX_CHUNKS_PER_OP); i < s; i++)
- {
- Chunk chunk = unbound.get(i);
- provider.chunksToUnload.add(ChunkHash.chunkToKey(chunk.xPosition, chunk.zPosition));
- }
-
- if(unbound.size() - Math.min(unbound.size(), MAX_CHUNKS_PER_OP) > unboundLimit)
- minChunkDiff = 0;
- else
- minChunkDiff = unboundLimit - unbound.size();
- }
- else
- {
- minChunkDiff = unboundLimit - unbound.size();
- }
-
- lastGCTime = curTime;
- lastChunkCount = provider.loadedChunkHashMap.size() - provider.chunksToUnload.size();
- }
- }
-
- private static class ChunkComparator implements Comparator
- {
- private int curTime;
-
- public ChunkComparator(int curTime)
- {
- this.curTime = curTime;
- }
-
- @Override
- public int compare(Chunk c1, Chunk c2)
- {
- float c = (float)Math.max(curTime - c1.getLoadTime(), _10_MINUTES)/(float)Math.max(curTime - c1.getUnbindTime(), 1)
- - (float)Math.max(curTime - c2.getLoadTime(), _10_MINUTES)/(float)Math.max(curTime - c2.getUnbindTime(), 1);
- return c == 0 ? 0 : c < 0 ? -1 : 1;
- }
- };
-}
+package org.ultramine.server.chunk;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Set;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.world.ChunkCoordIntPair;
+import net.minecraft.world.WorldServer;
+import net.minecraft.world.chunk.Chunk;
+import net.minecraft.world.gen.ChunkProviderServer;
+
+@SideOnly(Side.SERVER)
+public class ChunkGC
+{
+ private static final int MIN_GC_INTERVAL = 100;
+ private static final int MAX_UNLOAD_QUEUE_SIZE = 128;
+ private static final int MAX_CHUNKS_PER_OP = 1024;
+ private static final int _10_MINUTES = 20*60*10;
+
+ private final ChunkProviderServer provider;
+ private final WorldServer world;
+
+ private int lastGCTime;
+ private int lastChunkCount;
+ private int minChunkDiff;
+
+ public ChunkGC(ChunkProviderServer provider)
+ {
+ this.provider = provider;
+ this.world = provider.worldObj;
+ }
+
+ public void onTick()
+ {
+ int confCacheSize = world.getConfig().chunkLoading.chunkCacheSize;
+ int chunksPerPlayer = (int)Math.pow(world.getConfig().chunkLoading.viewDistance*2 + 1, 2);
+ int boundChunks = world.playerEntities.size()*chunksPerPlayer + world.getPersistentChunks().size();
+ int chunkLimit = boundChunks + confCacheSize + MAX_CHUNKS_PER_OP;
+
+ int curTime = world.func_73046_m().getTickCounter();
+ int unloadQueueSize = provider.chunksToUnload.size();
+ int chunkCount = provider.loadedChunkHashMap.size() - unloadQueueSize;
+ int timePassed = curTime - lastGCTime;
+ int chunkDiff = chunkCount - lastChunkCount;
+
+ if(chunkCount > chunkLimit && timePassed > MIN_GC_INTERVAL && unloadQueueSize < MAX_UNLOAD_QUEUE_SIZE && (minChunkDiff == 0 || chunkDiff > minChunkDiff))
+ {
+ Set persistentChunks = world.getPersistentChunks().keySet();
+ Collection all = provider.loadedChunkHashMap.valueCollection();
+ List unbound = new ArrayList(all.size() - boundChunks);
+ for(Chunk chunk : all)
+ {
+ ChunkBindState state = chunk.getBindState();
+ if(state.canUnload())
+ {
+ unbound.add(chunk);
+ }
+ else if(state.isLeak() && curTime - chunk.getUnbindTime() > _10_MINUTES)
+ {
+ if(persistentChunks.contains(chunk.getChunkCoordIntPair()))
+ {
+ if(state != ChunkBindState.FORGE)
+ chunk.setBindState(ChunkBindState.FORGE);
+ chunk.updateUnbindTime();
+ }
+ else
+ {
+ chunk.unbind();
+ unbound.add(chunk);
+ }
+ }
+ }
+
+ int unboundLimit = confCacheSize + MAX_CHUNKS_PER_OP + unloadQueueSize;
+
+ if(unbound.size() > unboundLimit)
+ {
+ //performing GC
+ Collections.sort(unbound, new ChunkComparator(curTime));
+
+ for(int i = 0, s = Math.min(unbound.size(), MAX_CHUNKS_PER_OP); i < s; i++)
+ {
+ Chunk chunk = unbound.get(i);
+ provider.chunksToUnload.add(ChunkHash.chunkToKey(chunk.xPosition, chunk.zPosition));
+ }
+
+ if(unbound.size() - Math.min(unbound.size(), MAX_CHUNKS_PER_OP) > unboundLimit)
+ minChunkDiff = 0;
+ else
+ minChunkDiff = unboundLimit - unbound.size();
+ }
+ else
+ {
+ minChunkDiff = unboundLimit - unbound.size();
+ }
+
+ lastGCTime = curTime;
+ lastChunkCount = provider.loadedChunkHashMap.size() - provider.chunksToUnload.size();
+ }
+ }
+
+ private static class ChunkComparator implements Comparator
+ {
+ private int curTime;
+
+ public ChunkComparator(int curTime)
+ {
+ this.curTime = curTime;
+ }
+
+ @Override
+ public int compare(Chunk c1, Chunk c2)
+ {
+ float c = (float)Math.max(curTime - c1.getLoadTime(), _10_MINUTES)/(float)Math.max(curTime - c1.getUnbindTime(), 1)
+ - (float)Math.max(curTime - c2.getLoadTime(), _10_MINUTES)/(float)Math.max(curTime - c2.getUnbindTime(), 1);
+ return c == 0 ? 0 : c < 0 ? -1 : 1;
+ }
+ };
+}
diff --git a/src/main/java/org/ultramine/server/chunk/ChunkLoadCallbackRunnable.java b/src/main/java/org/ultramine/server/chunk/ChunkLoadCallbackRunnable.java
index e42c420..cb6de6b 100644
--- a/src/main/java/org/ultramine/server/chunk/ChunkLoadCallbackRunnable.java
+++ b/src/main/java/org/ultramine/server/chunk/ChunkLoadCallbackRunnable.java
@@ -1,29 +1,29 @@
-package org.ultramine.server.chunk;
-
-import net.minecraft.world.chunk.Chunk;
-
-public class ChunkLoadCallbackRunnable implements IChunkLoadCallback
-{
- private final Runnable run;
-
- public ChunkLoadCallbackRunnable(Runnable run)
- {
- this.run = run;
- }
-
- @Override
- public void onChunkLoaded(Chunk chunk)
- {
- run.run();
- }
-
- public int hashCode()
- {
- return run.hashCode();
- }
-
- public boolean equals(Object o)
- {
- return o instanceof ChunkLoadCallbackRunnable && ((ChunkLoadCallbackRunnable)o).run == run;
- }
-}
+package org.ultramine.server.chunk;
+
+import net.minecraft.world.chunk.Chunk;
+
+public class ChunkLoadCallbackRunnable implements IChunkLoadCallback
+{
+ private final Runnable run;
+
+ public ChunkLoadCallbackRunnable(Runnable run)
+ {
+ this.run = run;
+ }
+
+ @Override
+ public void onChunkLoaded(Chunk chunk)
+ {
+ run.run();
+ }
+
+ public int hashCode()
+ {
+ return run.hashCode();
+ }
+
+ public boolean equals(Object o)
+ {
+ return o instanceof ChunkLoadCallbackRunnable && ((ChunkLoadCallbackRunnable)o).run == run;
+ }
+}
diff --git a/src/main/java/org/ultramine/server/chunk/ChunkSendManager.java b/src/main/java/org/ultramine/server/chunk/ChunkSendManager.java
index da0c716..25477e0 100644
--- a/src/main/java/org/ultramine/server/chunk/ChunkSendManager.java
+++ b/src/main/java/org/ultramine/server/chunk/ChunkSendManager.java
@@ -1,401 +1,401 @@
-package org.ultramine.server.chunk;
-
-import gnu.trove.TCollections;
-import gnu.trove.iterator.TIntIterator;
-import gnu.trove.set.TIntSet;
-import gnu.trove.set.hash.TIntHashSet;
-import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.GenericFutureListener;
-
-import java.util.List;
-import java.util.Queue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.ultramine.server.util.BlockFace;
-import org.ultramine.server.util.ChunkCoordComparator;
-import org.ultramine.server.util.TIntArrayListImpl;
-
-import com.google.common.collect.Queues;
-
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.network.Packet;
-import net.minecraft.network.play.server.S21PacketChunkData;
-import net.minecraft.server.management.PlayerManager;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.MathHelper;
-import net.minecraft.world.WorldServer;
-import net.minecraft.world.chunk.Chunk;
-import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.event.world.ChunkWatchEvent;
-
-public class ChunkSendManager
-{
- private static final ExecutorService executor = Executors.newFixedThreadPool(1);
- private static final int MAX_QUEUE_SIZE = 8;
- private static final int DEFAULT_RATE = 3;
- private static final double MIN_RATE = 0.2d;
- private static final double MAX_RATE = 8d;
-
- private final EntityPlayerMP player;
- private PlayerManager manager;
- private BlockFace lastFace;
- private int lastViewDistance;
-
- private final TIntArrayListImpl toSend = new TIntArrayListImpl(441);
- private final TIntSet sending = TCollections.synchronizedSet(new TIntHashSet());
- private final TIntSet sended = new TIntHashSet();
- private final Queue toUpdate = Queues.newConcurrentLinkedQueue();
- private final Queue toUnload = Queues.newConcurrentLinkedQueue();
- private final AtomicInteger sendingQueueSize = new AtomicInteger();
-
- private int lastQueueSize;
- private double rate = DEFAULT_RATE;
- private int intervalCounter = 1;
-
- public ChunkSendManager(EntityPlayerMP player)
- {
- this.player = player;
- }
-
- private int getViewDistance()
- {
- return Math.min(manager.getWorldServer().getConfig().chunkLoading.viewDistance, player.getRenderDistance());
- }
-
- private void sortSendQueue()
- {
- int cx = MathHelper.floor_double(player.posX) >> 4;
- int cz = MathHelper.floor_double(player.posZ) >> 4;
- toSend.sort(ChunkCoordComparator.get(lastFace = BlockFace.yawToFace(player.rotationYaw), cx, cz));
- }
-
- private void checkDistance()
- {
- int curView = getViewDistance();
- if(curView != lastViewDistance)
- {
- int cx = MathHelper.floor_double(player.posX) >> 4;
- int cz = MathHelper.floor_double(player.posZ) >> 4;
-
- if(curView < lastViewDistance)
- {
- for(TIntIterator it = toSend.iterator(); it.hasNext();)
- {
- int key = it.next();
- if(!overlaps(cx, cz, ChunkHash.keyToX(key), ChunkHash.keyToZ(key), curView))
- it.remove();
- }
-
- for(TIntIterator it = sending.iterator(); it.hasNext();)
- {
- int key = it.next();
- if(!overlaps(cx, cz, ChunkHash.keyToX(key), ChunkHash.keyToZ(key), curView))
- it.remove();
- }
-
- for(TIntIterator it = sended.iterator(); it.hasNext();)
- {
- int key = it.next();
- if(!overlaps(cx, cz, ChunkHash.keyToX(key), ChunkHash.keyToZ(key), curView))
- {
- PlayerManager.PlayerInstance pi = manager.getOrCreateChunkWatcher(ChunkHash.keyToX(key), ChunkHash.keyToZ(key), false);
- if(pi != null) pi.removePlayer(player);
- it.remove();
- }
- }
- }
- else
- {
- for (int x = cx - curView; x <= cx + curView; ++x)
- {
- for (int z = cz - curView; z <= cz + curView; ++z)
- {
- int key = ChunkHash.chunkToKey(x, z);
- if(!toSend.contains(key) && !sended.contains(key) && !sending.contains(key))
- {
- toSend.add(key);
- }
- }
- }
- }
-
- lastViewDistance = curView;
- sortSendQueue();
- }
- }
-
- public void addTo(PlayerManager manager)
- {
- if(this.manager != null) throw new IllegalStateException("PlayerManager already set");
- this.manager = manager;
-
- player.managedPosX = player.posX;
- player.managedPosZ = player.posZ;
-
- int cx = MathHelper.floor_double(player.posX) >> 4;
- int cz = MathHelper.floor_double(player.posZ) >> 4;
- int viewRadius = lastViewDistance = getViewDistance();
-
- for (int x = cx - viewRadius; x <= cx + viewRadius; ++x)
- {
- for (int z = cz - viewRadius; z <= cz + viewRadius; ++z)
- {
- toSend.add(ChunkHash.chunkToKey(x, z));
- }
- }
-
- sortSendQueue();
-
- sendChunks(Math.max(1, (int)rate));
- }
-
- public void removeFrom(PlayerManager manager)
- {
- if(this.manager == null) return;
- if(this.manager != manager) throw new IllegalStateException();
-
- toSend.clear();
- sending.clear();
-
- for(TIntIterator it = sended.iterator(); it.hasNext();)
- {
- int key = it.next();
- PlayerManager.PlayerInstance pi = manager.getOrCreateChunkWatcher(ChunkHash.keyToX(key), ChunkHash.keyToZ(key), false);
- if (pi != null) pi.removePlayer(player);
- }
-
- sended.clear();
- this.manager = null;
- }
-
- public void update()
- {
- if(!toSend.isEmpty())
- {
- int queueSize = sendingQueueSize.get();
-
- if(queueSize == 0)
- {
- rate += 0.14;
- }
- else if(queueSize < DEFAULT_RATE)
- {
- rate += 0.07;
- }
- else if(queueSize > lastQueueSize)
- {
- if(queueSize > MAX_QUEUE_SIZE)
- rate -= 0.14;
- else
- rate -= 0.07;
- }
- if(rate < MIN_RATE) rate = MIN_RATE;
- else if(rate > MAX_RATE) rate = MAX_RATE;
-
- if(queueSize == 0 || (queueSize != lastQueueSize && queueSize <= MAX_QUEUE_SIZE))
- {
- lastQueueSize = queueSize;
-
- if(rate >= 1)
- {
- sendChunks((int)rate);
- }
- else
- {
- int interval = Math.max(1, (int)(1/rate));
- if(intervalCounter++ >= interval)
- {
- intervalCounter = 1;
- sendChunks(1);
- }
- }
-
- }
- }
-
- while(!toUpdate.isEmpty())
- {
- Chunk chunk = toUpdate.poll();
- int key = ChunkHash.chunkToKey(chunk.xPosition, chunk.zPosition);
-
- if(sending.contains(key))
- {
- manager.getOrCreateChunkWatcher(chunk.xPosition, chunk.zPosition, true).addPlayer(player);
-
- List> tes = manager.getWorldServer().func_147486_a(chunk.xPosition * 16, 0, chunk.zPosition * 16, chunk.xPosition * 16 + 15, 256, chunk.zPosition * 16 + 15);
- for(Object o : tes)
- {
- TileEntity te = (TileEntity)o;
- Packet packet = te.getDescriptionPacket();
-
- if (packet != null)
- {
- player.playerNetServerHandler.sendPacket(packet);
- }
- }
-
- manager.getWorldServer().getEntityTracker().func_85172_a(player, chunk);
- MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.Watch(chunk.getChunkCoordIntPair(), player));
-
- sended.add(key);
- sending.remove(key);
- }
- else
- {
- player.playerNetServerHandler.sendPacket(S21PacketChunkData.makeForUnload(chunk));
-
- PlayerManager.PlayerInstance pi = manager.getOrCreateChunkWatcher(chunk.xPosition, chunk.zPosition, false);
- if (pi == null)
- ((WorldServer)chunk.worldObj).theChunkProviderServer.unbindChunk(chunk);
- }
- }
-
- while(!toUnload.isEmpty())
- {
- Chunk chunk = toUnload.poll();
-
- PlayerManager.PlayerInstance pi = manager.getOrCreateChunkWatcher(chunk.xPosition, chunk.zPosition, false);
- if (pi == null)
- ((WorldServer)chunk.worldObj).theChunkProviderServer.unbindChunk(chunk);
- }
- }
-
- private void sendChunks(int count)
- {
- count = Math.min(count, toSend.size());
- for(int i = 0; i < count; i++)
- {
- int key = toSend.get(i);
- sending.add(key);
- sendingQueueSize.incrementAndGet();
- int ncx = ChunkHash.keyToX(key);
- int ncz = ChunkHash.keyToZ(key);
- manager.getWorldServer().theChunkProviderServer.loadAsync(ncx, ncz, chunkLoadCallback);
- }
- toSend.remove(0, count);
- }
-
- public void updatePlayerPertinentChunks()
- {
- checkDistance();
-
- int cx = MathHelper.floor_double(player.posX) >> 4;
- int cz = MathHelper.floor_double(player.posZ) >> 4;
- double d0 = player.managedPosX - player.posX;
- double d1 = player.managedPosZ - player.posZ;
- double square = d0 * d0 + d1 * d1;
-
- boolean sorted = false;
-
- if (square >= 64.0D)
- {
- int lastX = MathHelper.floor_double(player.managedPosX) >> 4;
- int lastZ = MathHelper.floor_double(player.managedPosZ) >> 4;
- int view = getViewDistance();
- int movX = cx - lastX;
- int movZ = cz - lastZ;
-
- if (movX != 0 || movZ != 0)
- {
- for (int x = cx - view; x <= cx + view; ++x)
- {
- for (int z = cz - view; z <= cz + view; ++z)
- {
- if (!overlaps(x, z, lastX, lastZ, view))
- {
- toSend.add(ChunkHash.chunkToKey(x, z));
- }
-
- if (!overlaps(x - movX, z - movZ, cx, cz, view))
- {
- int key = ChunkHash.chunkToKey(x - movX, z - movZ);
- if(!toSend.remove(key))
- {
- if(sended.contains(key))
- {
- PlayerManager.PlayerInstance pi = manager.getOrCreateChunkWatcher(x - movX, z - movZ, false);
- if(pi != null) pi.removePlayer(player);
- sended.remove(key);
- }
- else
- {
- sending.remove(key);
- }
- }
- }
- }
- }
-
- sortSendQueue();
- sorted = true;
- player.managedPosX = player.posX;
- player.managedPosZ = player.posZ;
- }
- }
-
- if(!sorted)
- {
- BlockFace face = BlockFace.yawToFace(player.rotationYaw);
- if(face != lastFace)
- {
- sortSendQueue();
- }
- }
- }
-
- private boolean overlaps(int x, int z, int lastX, int lastZ, int radius)
- {
- int movX = x - lastX;
- int movZ = z - lastZ;
- return movX >= -radius && movX <= radius ? movZ >= -radius && movZ <= radius : false;
- }
-
-
-
-
- private IChunkLoadCallback chunkLoadCallback = new IChunkLoadCallback()
- {
- @Override
- public void onChunkLoaded(Chunk chunk)
- {
- chunk.setBindState(ChunkBindState.PLAYER);
- executor.execute(new CompressAndSendChunkTask(chunk));
- }
- };
-
- private class CompressAndSendChunkTask implements Runnable
- {
- private final Chunk chunk;
-
- public CompressAndSendChunkTask(Chunk chunk)
- {
- this.chunk = chunk;
- }
-
- @Override
- public void run()
- {
- if(sending.contains(ChunkHash.chunkToKey(chunk.xPosition, chunk.zPosition)))
- {
- player.playerNetServerHandler.netManager.scheduleOutboundPacket(S21PacketChunkData.makeDeflated(chunk),
- new GenericFutureListener>()
- {
- @Override
- public void operationComplete(Future future) throws Exception
- {
- sendingQueueSize.decrementAndGet();
- }
- });
-
- toUpdate.add(chunk);
- }
- else
- {
- sendingQueueSize.decrementAndGet();
- toUnload.add(chunk);
- }
- }
- }
-}
+package org.ultramine.server.chunk;
+
+import gnu.trove.TCollections;
+import gnu.trove.iterator.TIntIterator;
+import gnu.trove.set.TIntSet;
+import gnu.trove.set.hash.TIntHashSet;
+import io.netty.util.concurrent.Future;
+import io.netty.util.concurrent.GenericFutureListener;
+
+import java.util.List;
+import java.util.Queue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.ultramine.server.util.BlockFace;
+import org.ultramine.server.util.ChunkCoordComparator;
+import org.ultramine.server.util.TIntArrayListImpl;
+
+import com.google.common.collect.Queues;
+
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.network.Packet;
+import net.minecraft.network.play.server.S21PacketChunkData;
+import net.minecraft.server.management.PlayerManager;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.WorldServer;
+import net.minecraft.world.chunk.Chunk;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.world.ChunkWatchEvent;
+
+public class ChunkSendManager
+{
+ private static final ExecutorService executor = Executors.newFixedThreadPool(1);
+ private static final int MAX_QUEUE_SIZE = 8;
+ private static final int DEFAULT_RATE = 3;
+ private static final double MIN_RATE = 0.2d;
+ private static final double MAX_RATE = 8d;
+
+ private final EntityPlayerMP player;
+ private PlayerManager manager;
+ private BlockFace lastFace;
+ private int lastViewDistance;
+
+ private final TIntArrayListImpl toSend = new TIntArrayListImpl(441);
+ private final TIntSet sending = TCollections.synchronizedSet(new TIntHashSet());
+ private final TIntSet sended = new TIntHashSet();
+ private final Queue toUpdate = Queues.newConcurrentLinkedQueue();
+ private final Queue toUnload = Queues.newConcurrentLinkedQueue();
+ private final AtomicInteger sendingQueueSize = new AtomicInteger();
+
+ private int lastQueueSize;
+ private double rate = DEFAULT_RATE;
+ private int intervalCounter = 1;
+
+ public ChunkSendManager(EntityPlayerMP player)
+ {
+ this.player = player;
+ }
+
+ private int getViewDistance()
+ {
+ return Math.min(manager.getWorldServer().getConfig().chunkLoading.viewDistance, player.getRenderDistance());
+ }
+
+ private void sortSendQueue()
+ {
+ int cx = MathHelper.floor_double(player.posX) >> 4;
+ int cz = MathHelper.floor_double(player.posZ) >> 4;
+ toSend.sort(ChunkCoordComparator.get(lastFace = BlockFace.yawToFace(player.rotationYaw), cx, cz));
+ }
+
+ private void checkDistance()
+ {
+ int curView = getViewDistance();
+ if(curView != lastViewDistance)
+ {
+ int cx = MathHelper.floor_double(player.posX) >> 4;
+ int cz = MathHelper.floor_double(player.posZ) >> 4;
+
+ if(curView < lastViewDistance)
+ {
+ for(TIntIterator it = toSend.iterator(); it.hasNext();)
+ {
+ int key = it.next();
+ if(!overlaps(cx, cz, ChunkHash.keyToX(key), ChunkHash.keyToZ(key), curView))
+ it.remove();
+ }
+
+ for(TIntIterator it = sending.iterator(); it.hasNext();)
+ {
+ int key = it.next();
+ if(!overlaps(cx, cz, ChunkHash.keyToX(key), ChunkHash.keyToZ(key), curView))
+ it.remove();
+ }
+
+ for(TIntIterator it = sended.iterator(); it.hasNext();)
+ {
+ int key = it.next();
+ if(!overlaps(cx, cz, ChunkHash.keyToX(key), ChunkHash.keyToZ(key), curView))
+ {
+ PlayerManager.PlayerInstance pi = manager.getOrCreateChunkWatcher(ChunkHash.keyToX(key), ChunkHash.keyToZ(key), false);
+ if(pi != null) pi.removePlayer(player);
+ it.remove();
+ }
+ }
+ }
+ else
+ {
+ for (int x = cx - curView; x <= cx + curView; ++x)
+ {
+ for (int z = cz - curView; z <= cz + curView; ++z)
+ {
+ int key = ChunkHash.chunkToKey(x, z);
+ if(!toSend.contains(key) && !sended.contains(key) && !sending.contains(key))
+ {
+ toSend.add(key);
+ }
+ }
+ }
+ }
+
+ lastViewDistance = curView;
+ sortSendQueue();
+ }
+ }
+
+ public void addTo(PlayerManager manager)
+ {
+ if(this.manager != null) throw new IllegalStateException("PlayerManager already set");
+ this.manager = manager;
+
+ player.managedPosX = player.posX;
+ player.managedPosZ = player.posZ;
+
+ int cx = MathHelper.floor_double(player.posX) >> 4;
+ int cz = MathHelper.floor_double(player.posZ) >> 4;
+ int viewRadius = lastViewDistance = getViewDistance();
+
+ for (int x = cx - viewRadius; x <= cx + viewRadius; ++x)
+ {
+ for (int z = cz - viewRadius; z <= cz + viewRadius; ++z)
+ {
+ toSend.add(ChunkHash.chunkToKey(x, z));
+ }
+ }
+
+ sortSendQueue();
+
+ sendChunks(Math.max(1, (int)rate));
+ }
+
+ public void removeFrom(PlayerManager manager)
+ {
+ if(this.manager == null) return;
+ if(this.manager != manager) throw new IllegalStateException();
+
+ toSend.clear();
+ sending.clear();
+
+ for(TIntIterator it = sended.iterator(); it.hasNext();)
+ {
+ int key = it.next();
+ PlayerManager.PlayerInstance pi = manager.getOrCreateChunkWatcher(ChunkHash.keyToX(key), ChunkHash.keyToZ(key), false);
+ if (pi != null) pi.removePlayer(player);
+ }
+
+ sended.clear();
+ this.manager = null;
+ }
+
+ public void update()
+ {
+ if(!toSend.isEmpty())
+ {
+ int queueSize = sendingQueueSize.get();
+
+ if(queueSize == 0)
+ {
+ rate += 0.14;
+ }
+ else if(queueSize < DEFAULT_RATE)
+ {
+ rate += 0.07;
+ }
+ else if(queueSize > lastQueueSize)
+ {
+ if(queueSize > MAX_QUEUE_SIZE)
+ rate -= 0.14;
+ else
+ rate -= 0.07;
+ }
+ if(rate < MIN_RATE) rate = MIN_RATE;
+ else if(rate > MAX_RATE) rate = MAX_RATE;
+
+ if(queueSize == 0 || (queueSize != lastQueueSize && queueSize <= MAX_QUEUE_SIZE))
+ {
+ lastQueueSize = queueSize;
+
+ if(rate >= 1)
+ {
+ sendChunks((int)rate);
+ }
+ else
+ {
+ int interval = Math.max(1, (int)(1/rate));
+ if(intervalCounter++ >= interval)
+ {
+ intervalCounter = 1;
+ sendChunks(1);
+ }
+ }
+
+ }
+ }
+
+ while(!toUpdate.isEmpty())
+ {
+ Chunk chunk = toUpdate.poll();
+ int key = ChunkHash.chunkToKey(chunk.xPosition, chunk.zPosition);
+
+ if(sending.contains(key))
+ {
+ manager.getOrCreateChunkWatcher(chunk.xPosition, chunk.zPosition, true).addPlayer(player);
+
+ List> tes = manager.getWorldServer().func_147486_a(chunk.xPosition * 16, 0, chunk.zPosition * 16, chunk.xPosition * 16 + 15, 256, chunk.zPosition * 16 + 15);
+ for(Object o : tes)
+ {
+ TileEntity te = (TileEntity)o;
+ Packet packet = te.getDescriptionPacket();
+
+ if (packet != null)
+ {
+ player.playerNetServerHandler.sendPacket(packet);
+ }
+ }
+
+ manager.getWorldServer().getEntityTracker().func_85172_a(player, chunk);
+ MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.Watch(chunk.getChunkCoordIntPair(), player));
+
+ sended.add(key);
+ sending.remove(key);
+ }
+ else
+ {
+ player.playerNetServerHandler.sendPacket(S21PacketChunkData.makeForUnload(chunk));
+
+ PlayerManager.PlayerInstance pi = manager.getOrCreateChunkWatcher(chunk.xPosition, chunk.zPosition, false);
+ if (pi == null)
+ ((WorldServer)chunk.worldObj).theChunkProviderServer.unbindChunk(chunk);
+ }
+ }
+
+ while(!toUnload.isEmpty())
+ {
+ Chunk chunk = toUnload.poll();
+
+ PlayerManager.PlayerInstance pi = manager.getOrCreateChunkWatcher(chunk.xPosition, chunk.zPosition, false);
+ if (pi == null)
+ ((WorldServer)chunk.worldObj).theChunkProviderServer.unbindChunk(chunk);
+ }
+ }
+
+ private void sendChunks(int count)
+ {
+ count = Math.min(count, toSend.size());
+ for(int i = 0; i < count; i++)
+ {
+ int key = toSend.get(i);
+ sending.add(key);
+ sendingQueueSize.incrementAndGet();
+ int ncx = ChunkHash.keyToX(key);
+ int ncz = ChunkHash.keyToZ(key);
+ manager.getWorldServer().theChunkProviderServer.loadAsync(ncx, ncz, chunkLoadCallback);
+ }
+ toSend.remove(0, count);
+ }
+
+ public void updatePlayerPertinentChunks()
+ {
+ checkDistance();
+
+ int cx = MathHelper.floor_double(player.posX) >> 4;
+ int cz = MathHelper.floor_double(player.posZ) >> 4;
+ double d0 = player.managedPosX - player.posX;
+ double d1 = player.managedPosZ - player.posZ;
+ double square = d0 * d0 + d1 * d1;
+
+ boolean sorted = false;
+
+ if (square >= 64.0D)
+ {
+ int lastX = MathHelper.floor_double(player.managedPosX) >> 4;
+ int lastZ = MathHelper.floor_double(player.managedPosZ) >> 4;
+ int view = getViewDistance();
+ int movX = cx - lastX;
+ int movZ = cz - lastZ;
+
+ if (movX != 0 || movZ != 0)
+ {
+ for (int x = cx - view; x <= cx + view; ++x)
+ {
+ for (int z = cz - view; z <= cz + view; ++z)
+ {
+ if (!overlaps(x, z, lastX, lastZ, view))
+ {
+ toSend.add(ChunkHash.chunkToKey(x, z));
+ }
+
+ if (!overlaps(x - movX, z - movZ, cx, cz, view))
+ {
+ int key = ChunkHash.chunkToKey(x - movX, z - movZ);
+ if(!toSend.remove(key))
+ {
+ if(sended.contains(key))
+ {
+ PlayerManager.PlayerInstance pi = manager.getOrCreateChunkWatcher(x - movX, z - movZ, false);
+ if(pi != null) pi.removePlayer(player);
+ sended.remove(key);
+ }
+ else
+ {
+ sending.remove(key);
+ }
+ }
+ }
+ }
+ }
+
+ sortSendQueue();
+ sorted = true;
+ player.managedPosX = player.posX;
+ player.managedPosZ = player.posZ;
+ }
+ }
+
+ if(!sorted)
+ {
+ BlockFace face = BlockFace.yawToFace(player.rotationYaw);
+ if(face != lastFace)
+ {
+ sortSendQueue();
+ }
+ }
+ }
+
+ private boolean overlaps(int x, int z, int lastX, int lastZ, int radius)
+ {
+ int movX = x - lastX;
+ int movZ = z - lastZ;
+ return movX >= -radius && movX <= radius ? movZ >= -radius && movZ <= radius : false;
+ }
+
+
+
+
+ private IChunkLoadCallback chunkLoadCallback = new IChunkLoadCallback()
+ {
+ @Override
+ public void onChunkLoaded(Chunk chunk)
+ {
+ chunk.setBindState(ChunkBindState.PLAYER);
+ executor.execute(new CompressAndSendChunkTask(chunk));
+ }
+ };
+
+ private class CompressAndSendChunkTask implements Runnable
+ {
+ private final Chunk chunk;
+
+ public CompressAndSendChunkTask(Chunk chunk)
+ {
+ this.chunk = chunk;
+ }
+
+ @Override
+ public void run()
+ {
+ if(sending.contains(ChunkHash.chunkToKey(chunk.xPosition, chunk.zPosition)))
+ {
+ player.playerNetServerHandler.netManager.scheduleOutboundPacket(S21PacketChunkData.makeDeflated(chunk),
+ new GenericFutureListener>()
+ {
+ @Override
+ public void operationComplete(Future future) throws Exception
+ {
+ sendingQueueSize.decrementAndGet();
+ }
+ });
+
+ toUpdate.add(chunk);
+ }
+ else
+ {
+ sendingQueueSize.decrementAndGet();
+ toUnload.add(chunk);
+ }
+ }
+ }
+}
diff --git a/src/main/java/org/ultramine/server/log/UMConsoleLayout.java b/src/main/java/org/ultramine/server/log/UMConsoleLayout.java
index 348cfb4..87e3508 100644
--- a/src/main/java/org/ultramine/server/log/UMConsoleLayout.java
+++ b/src/main/java/org/ultramine/server/log/UMConsoleLayout.java
@@ -1,105 +1,105 @@
-package org.ultramine.server.log;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.nio.charset.Charset;
-import java.text.SimpleDateFormat;
-import java.util.Collections;
-import java.util.Map;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.helpers.Charsets;
-import org.apache.logging.log4j.core.helpers.Constants;
-import org.apache.logging.log4j.core.layout.AbstractStringLayout;
-
-@Plugin(name = "UMConsoleLayout", category = "Core", elementType = "layout", printObject = false)
-public class UMConsoleLayout extends AbstractStringLayout
-{
- private static final boolean useUMConsole = Boolean.parseBoolean(System.getProperty("org.ultramine.server.umconsole"));
- private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
-
- protected UMConsoleLayout(Charset charset)
- {
- super(charset);
- }
-
- @Override
- public String toSerializable(LogEvent event)
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append('[');
- sb.append(dateFormat.format(event.getMillis()));
- sb.append("] ");
-
- sb.append('[');
- Level level = event.getLevel();
- if(useUMConsole)
- {
- if(level == Level.WARN)
- sb.append("\u00A7e");
- else if(level == Level.ERROR)
- sb.append("\u00A7c");
- else if(level == Level.FATAL)
- sb.append("\u00A74");
- }
- String levelS = event.getLevel().toString();
- int llen = levelS.length();
- if(llen > 4)
- levelS = levelS.substring(0, 4);
- sb.append(levelS);
- if(llen < 4)
- sb.append(' ');
- if(useUMConsole && (level == Level.WARN || level == Level.ERROR || level == Level.FATAL))
- sb.append("\u00A7r");
- sb.append("] ");
-
- String msg = event.getMessage().getFormattedMessage();
- if(useUMConsole)
- {
- sb.append(msg);
- }
- else
- {
- for(int i = 0, s = msg.length(); i < s; i++)
- {
- char c = msg.charAt(i);
- if(c == '\u00a7')
- {
- i++;
- continue;
- }
- sb.append(c);
- }
- }
-
- Throwable t = event.getThrown();
- if(t != null)
- {
- StringWriter w = new StringWriter();
- t.printStackTrace(new PrintWriter(w));
- sb.append(Constants.LINE_SEP);
- sb.append(w.toString());
- }
-
- sb.append(Constants.LINE_SEP);
-
- return sb.toString();
- }
-
- @Override
- public Map getContentFormat()
- {
- return Collections.emptyMap();
- }
-
- @PluginFactory
- public static UMConsoleLayout createLayout(@PluginAttribute("charset") final String charsetName)
- {
- return new UMConsoleLayout(Charsets.getSupportedCharset(charsetName));
- }
-}
+package org.ultramine.server.log;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.charset.Charset;
+import java.text.SimpleDateFormat;
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginFactory;
+import org.apache.logging.log4j.core.helpers.Charsets;
+import org.apache.logging.log4j.core.helpers.Constants;
+import org.apache.logging.log4j.core.layout.AbstractStringLayout;
+
+@Plugin(name = "UMConsoleLayout", category = "Core", elementType = "layout", printObject = false)
+public class UMConsoleLayout extends AbstractStringLayout
+{
+ private static final boolean useUMConsole = Boolean.parseBoolean(System.getProperty("org.ultramine.server.umconsole"));
+ private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+
+ protected UMConsoleLayout(Charset charset)
+ {
+ super(charset);
+ }
+
+ @Override
+ public String toSerializable(LogEvent event)
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append('[');
+ sb.append(dateFormat.format(event.getMillis()));
+ sb.append("] ");
+
+ sb.append('[');
+ Level level = event.getLevel();
+ if(useUMConsole)
+ {
+ if(level == Level.WARN)
+ sb.append("\u00A7e");
+ else if(level == Level.ERROR)
+ sb.append("\u00A7c");
+ else if(level == Level.FATAL)
+ sb.append("\u00A74");
+ }
+ String levelS = event.getLevel().toString();
+ int llen = levelS.length();
+ if(llen > 4)
+ levelS = levelS.substring(0, 4);
+ sb.append(levelS);
+ if(llen < 4)
+ sb.append(' ');
+ if(useUMConsole && (level == Level.WARN || level == Level.ERROR || level == Level.FATAL))
+ sb.append("\u00A7r");
+ sb.append("] ");
+
+ String msg = event.getMessage().getFormattedMessage();
+ if(useUMConsole)
+ {
+ sb.append(msg);
+ }
+ else
+ {
+ for(int i = 0, s = msg.length(); i < s; i++)
+ {
+ char c = msg.charAt(i);
+ if(c == '\u00a7')
+ {
+ i++;
+ continue;
+ }
+ sb.append(c);
+ }
+ }
+
+ Throwable t = event.getThrown();
+ if(t != null)
+ {
+ StringWriter w = new StringWriter();
+ t.printStackTrace(new PrintWriter(w));
+ sb.append(Constants.LINE_SEP);
+ sb.append(w.toString());
+ }
+
+ sb.append(Constants.LINE_SEP);
+
+ return sb.toString();
+ }
+
+ @Override
+ public Map getContentFormat()
+ {
+ return Collections.emptyMap();
+ }
+
+ @PluginFactory
+ public static UMConsoleLayout createLayout(@PluginAttribute("charset") final String charsetName)
+ {
+ return new UMConsoleLayout(Charsets.getSupportedCharset(charsetName));
+ }
+}
diff --git a/src/main/java/org/ultramine/server/util/BasicTypeParser.java b/src/main/java/org/ultramine/server/util/BasicTypeParser.java
index 4aa1ee6..76badff 100644
--- a/src/main/java/org/ultramine/server/util/BasicTypeParser.java
+++ b/src/main/java/org/ultramine/server/util/BasicTypeParser.java
@@ -1,85 +1,85 @@
-package org.ultramine.server.util;
-
-import net.minecraft.world.EnumDifficulty;
-
-public class BasicTypeParser
-{
- public static boolean isInt(String val)
- {
- int len = val.length();
- if(len > 11 || len == 0) return false;
- if(len > 9)
- {
- try
- {
- Integer.parseInt(val);
- return true;
- } catch(NumberFormatException e){return false;}
- }
-
- int i = 0;
- if(val.charAt(0) == '-')
- {
- i = 1;
- if(len == 1) return false;
- }
-
- for(; i < len; i++)
- {
- char c = val.charAt(i);
- if(c < '0' || c > '9') return false;
- }
-
- return true;
- }
-
- public static boolean isUnsignedInt(String val)
- {
- int len = val.length();
- if(len > 10 || len == 0) return false;
- if(len == 10)
- {
- try
- {
- if(Integer.parseInt(val) >= 0) return true;
- } catch(NumberFormatException e){return false;}
- }
-
- for(int i = 0; i < len; i++)
- {
- char c = val.charAt(i);
- if(c < '0' || c > '9') return false;
- }
-
- return true;
- }
-
- public static EnumDifficulty parseDifficulty(String str)
- {
- if(isUnsignedInt(str))
- {
- return EnumDifficulty.getDifficultyEnum(Math.min(Integer.parseInt(str), 3));
- }
-
- str = str.toLowerCase();
-
- if(str.equals("p") || str.equals("peaceful"))
- {
- return EnumDifficulty.PEACEFUL;
- }
- else if(str.equals("e") || str.equals("easy"))
- {
- return EnumDifficulty.EASY;
- }
- else if(str.equals("n") || str.equals("normal"))
- {
- return EnumDifficulty.NORMAL;
- }
- else if(str.equals("h") || str.equals("hard"))
- {
- return EnumDifficulty.HARD;
- }
-
- return null;
- }
-}
+package org.ultramine.server.util;
+
+import net.minecraft.world.EnumDifficulty;
+
+public class BasicTypeParser
+{
+ public static boolean isInt(String val)
+ {
+ int len = val.length();
+ if(len > 11 || len == 0) return false;
+ if(len > 9)
+ {
+ try
+ {
+ Integer.parseInt(val);
+ return true;
+ } catch(NumberFormatException e){return false;}
+ }
+
+ int i = 0;
+ if(val.charAt(0) == '-')
+ {
+ i = 1;
+ if(len == 1) return false;
+ }
+
+ for(; i < len; i++)
+ {
+ char c = val.charAt(i);
+ if(c < '0' || c > '9') return false;
+ }
+
+ return true;
+ }
+
+ public static boolean isUnsignedInt(String val)
+ {
+ int len = val.length();
+ if(len > 10 || len == 0) return false;
+ if(len == 10)
+ {
+ try
+ {
+ if(Integer.parseInt(val) >= 0) return true;
+ } catch(NumberFormatException e){return false;}
+ }
+
+ for(int i = 0; i < len; i++)
+ {
+ char c = val.charAt(i);
+ if(c < '0' || c > '9') return false;
+ }
+
+ return true;
+ }
+
+ public static EnumDifficulty parseDifficulty(String str)
+ {
+ if(isUnsignedInt(str))
+ {
+ return EnumDifficulty.getDifficultyEnum(Math.min(Integer.parseInt(str), 3));
+ }
+
+ str = str.toLowerCase();
+
+ if(str.equals("p") || str.equals("peaceful"))
+ {
+ return EnumDifficulty.PEACEFUL;
+ }
+ else if(str.equals("e") || str.equals("easy"))
+ {
+ return EnumDifficulty.EASY;
+ }
+ else if(str.equals("n") || str.equals("normal"))
+ {
+ return EnumDifficulty.NORMAL;
+ }
+ else if(str.equals("h") || str.equals("hard"))
+ {
+ return EnumDifficulty.HARD;
+ }
+
+ return null;
+ }
+}
diff --git a/src/main/java/org/ultramine/server/util/Resources.java b/src/main/java/org/ultramine/server/util/Resources.java
index 549a077..673dc13 100644
--- a/src/main/java/org/ultramine/server/util/Resources.java
+++ b/src/main/java/org/ultramine/server/util/Resources.java
@@ -1,34 +1,34 @@
-package org.ultramine.server.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.commons.io.Charsets;
-import org.apache.commons.io.IOUtils;
-
-public class Resources
-{
- public static InputStream getAsStream(String path)
- {
- return Resources.class.getResourceAsStream(path);
- }
-
- public static String getAsString(String path)
- {
- InputStream is = getAsStream(path);
- if(is == null)
- throw new RuntimeException("Requested resource not found: " + path);
- try
- {
- return IOUtils.toString(is, Charsets.UTF_8);
- }
- catch(IOException e)
- {
- throw new RuntimeException("Failed to load resource: " + path, e);
- }
- finally
- {
- IOUtils.closeQuietly(is);
- }
- }
-}
+package org.ultramine.server.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.io.Charsets;
+import org.apache.commons.io.IOUtils;
+
+public class Resources
+{
+ public static InputStream getAsStream(String path)
+ {
+ return Resources.class.getResourceAsStream(path);
+ }
+
+ public static String getAsString(String path)
+ {
+ InputStream is = getAsStream(path);
+ if(is == null)
+ throw new RuntimeException("Requested resource not found: " + path);
+ try
+ {
+ return IOUtils.toString(is, Charsets.UTF_8);
+ }
+ catch(IOException e)
+ {
+ throw new RuntimeException("Failed to load resource: " + path, e);
+ }
+ finally
+ {
+ IOUtils.closeQuietly(is);
+ }
+ }
+}
diff --git a/src/main/java/org/ultramine/server/util/WarpLocation.java b/src/main/java/org/ultramine/server/util/WarpLocation.java
index aee9522..28b15a2 100644
--- a/src/main/java/org/ultramine/server/util/WarpLocation.java
+++ b/src/main/java/org/ultramine/server/util/WarpLocation.java
@@ -1,61 +1,61 @@
-package org.ultramine.server.util;
-
-import net.minecraft.entity.player.EntityPlayer;
-
-public class WarpLocation
-{
- public int dimension;
- public double x;
- public double y;
- public double z;
- public float yaw;
- public float pitch;
- public double randomRadius;
-
- public WarpLocation(int dimension, double x, double y, double z, float yaw, float pitch, double randomRadius)
- {
- this.dimension = dimension;
- this.x = x;
- this.y = y;
- this.z = z;
- this.yaw = yaw;
- this.pitch = pitch;
- this.randomRadius = randomRadius;
- }
-
- public WarpLocation(int dimension, double x, double y, double z, float yaw, float pitch)
- {
- this(dimension, x, y, z, yaw, pitch, 0);
- }
-
- public WarpLocation(int dimension, double x, double y, double z)
- {
- this(dimension, x, y, z, 0, 0);
- }
-
- public void round()
- {
- x = (double)Math.round(x*100)/100.0;
- y = (double)Math.round(y*100)/100.0;
- z = (double)Math.round(z*100)/100.0;
-
- yaw = (float)Math.round(yaw*100)/100.0F;
- pitch = (float)Math.round(pitch*100)/100.0F;
- }
-
- public boolean equals(WarpLocation loc)
- {
- if(this == loc) return true;
- return
- Math.abs(x - loc.x) < 0.1 &&
- Math.abs(y - loc.y) < 0.1 &&
- Math.abs(z - loc.z) < 0.1;
- }
-
- public static WarpLocation getFromPlayer(EntityPlayer player)
- {
- WarpLocation s = new WarpLocation(player.dimension, player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
- s.round();
- return s;
- }
-}
+package org.ultramine.server.util;
+
+import net.minecraft.entity.player.EntityPlayer;
+
+public class WarpLocation
+{
+ public int dimension;
+ public double x;
+ public double y;
+ public double z;
+ public float yaw;
+ public float pitch;
+ public double randomRadius;
+
+ public WarpLocation(int dimension, double x, double y, double z, float yaw, float pitch, double randomRadius)
+ {
+ this.dimension = dimension;
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.yaw = yaw;
+ this.pitch = pitch;
+ this.randomRadius = randomRadius;
+ }
+
+ public WarpLocation(int dimension, double x, double y, double z, float yaw, float pitch)
+ {
+ this(dimension, x, y, z, yaw, pitch, 0);
+ }
+
+ public WarpLocation(int dimension, double x, double y, double z)
+ {
+ this(dimension, x, y, z, 0, 0);
+ }
+
+ public void round()
+ {
+ x = (double)Math.round(x*100)/100.0;
+ y = (double)Math.round(y*100)/100.0;
+ z = (double)Math.round(z*100)/100.0;
+
+ yaw = (float)Math.round(yaw*100)/100.0F;
+ pitch = (float)Math.round(pitch*100)/100.0F;
+ }
+
+ public boolean equals(WarpLocation loc)
+ {
+ if(this == loc) return true;
+ return
+ Math.abs(x - loc.x) < 0.1 &&
+ Math.abs(y - loc.y) < 0.1 &&
+ Math.abs(z - loc.z) < 0.1;
+ }
+
+ public static WarpLocation getFromPlayer(EntityPlayer player)
+ {
+ WarpLocation s = new WarpLocation(player.dimension, player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
+ s.round();
+ return s;
+ }
+}
diff --git a/src/main/java/org/ultramine/server/wempty/ChunkProviderEmpty.java b/src/main/java/org/ultramine/server/wempty/ChunkProviderEmpty.java
index d9b945d..42ce938 100644
--- a/src/main/java/org/ultramine/server/wempty/ChunkProviderEmpty.java
+++ b/src/main/java/org/ultramine/server/wempty/ChunkProviderEmpty.java
@@ -1,125 +1,125 @@
-package org.ultramine.server.wempty;
-
-import java.util.List;
-
-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;
-
-public class ChunkProviderEmpty implements IChunkProvider
-{
- private World world;
-
- public ChunkProviderEmpty(World world)
- {
- this.world = world;
- }
-
- @Override
- public boolean chunkExists(int var1, int var2)
- {
- return true;
- }
-
- @Override
- public Chunk provideChunk(int par1, int par2)
- {
- Chunk chunk = new Chunk(this.world, par1, par2);
-
- byte[] arr = chunk.getBiomeArray();
-
- for (int i = 0; i < arr.length; ++i)
- {
- arr[i] = (byte)BiomeGenBase.forest.biomeID;
- }
-
- chunk.generateSkylightMap();
-
- return chunk;
- }
-
- @Override
- public Chunk loadChunk(int var1, int var2)
- {
- return this.provideChunk(var1, var2);
- }
-
- @Override
- public void populate(IChunkProvider var1, int x, int z)
- {
- int bx = x << 4;
- int bz = z << 4;
-
- if((x > -2 && x < 2) && (z > -2 && z < 2))
- {
- for(int i = 0; i < 16; i++)
- {
- for(int j = 0; j < 16; j++)
- {
- world.setBlock(bx + i, 64, bz + j, Blocks.grass);
- }
- }
- }
- }
-
- @Override
- public boolean saveChunks(boolean var1, IProgressUpdate var2)
- {
- return true;
- }
-
- @Override
- public boolean unloadQueuedChunks()
- {
- return false;
- }
-
- @Override
- public boolean canSave()
- {
- return true;
- }
-
- @Override
- public String makeString()
- {
- return "EmptyWorldSource";
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public List getPossibleCreatures(EnumCreatureType var1, int var2, int var3, int var4)
- {
- return null;
- }
-
- @Override
- public ChunkPosition func_147416_a(World var1, String var2, int var3, int var4, int var5)
- {
- return null;
- }
-
- @Override
- public int getLoadedChunkCount()
- {
- return 0;
- }
-
- @Override
- public void recreateStructures(int var1, int var2)
- {
-
- }
-
- @Override
- public void saveExtraData()
- {
-
- }
-
-}
+package org.ultramine.server.wempty;
+
+import java.util.List;
+
+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;
+
+public class ChunkProviderEmpty implements IChunkProvider
+{
+ private World world;
+
+ public ChunkProviderEmpty(World world)
+ {
+ this.world = world;
+ }
+
+ @Override
+ public boolean chunkExists(int var1, int var2)
+ {
+ return true;
+ }
+
+ @Override
+ public Chunk provideChunk(int par1, int par2)
+ {
+ Chunk chunk = new Chunk(this.world, par1, par2);
+
+ byte[] arr = chunk.getBiomeArray();
+
+ for (int i = 0; i < arr.length; ++i)
+ {
+ arr[i] = (byte)BiomeGenBase.forest.biomeID;
+ }
+
+ chunk.generateSkylightMap();
+
+ return chunk;
+ }
+
+ @Override
+ public Chunk loadChunk(int var1, int var2)
+ {
+ return this.provideChunk(var1, var2);
+ }
+
+ @Override
+ public void populate(IChunkProvider var1, int x, int z)
+ {
+ int bx = x << 4;
+ int bz = z << 4;
+
+ if((x > -2 && x < 2) && (z > -2 && z < 2))
+ {
+ for(int i = 0; i < 16; i++)
+ {
+ for(int j = 0; j < 16; j++)
+ {
+ world.setBlock(bx + i, 64, bz + j, Blocks.grass);
+ }
+ }
+ }
+ }
+
+ @Override
+ public boolean saveChunks(boolean var1, IProgressUpdate var2)
+ {
+ return true;
+ }
+
+ @Override
+ public boolean unloadQueuedChunks()
+ {
+ return false;
+ }
+
+ @Override
+ public boolean canSave()
+ {
+ return true;
+ }
+
+ @Override
+ public String makeString()
+ {
+ return "EmptyWorldSource";
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public List getPossibleCreatures(EnumCreatureType var1, int var2, int var3, int var4)
+ {
+ return null;
+ }
+
+ @Override
+ public ChunkPosition func_147416_a(World var1, String var2, int var3, int var4, int var5)
+ {
+ return null;
+ }
+
+ @Override
+ public int getLoadedChunkCount()
+ {
+ return 0;
+ }
+
+ @Override
+ public void recreateStructures(int var1, int var2)
+ {
+
+ }
+
+ @Override
+ public void saveExtraData()
+ {
+
+ }
+
+}
diff --git a/src/main/java/org/ultramine/server/wempty/WorldProviderEmpty.java b/src/main/java/org/ultramine/server/wempty/WorldProviderEmpty.java
index 1c22ee8..9183131 100644
--- a/src/main/java/org/ultramine/server/wempty/WorldProviderEmpty.java
+++ b/src/main/java/org/ultramine/server/wempty/WorldProviderEmpty.java
@@ -1,20 +1,20 @@
-package org.ultramine.server.wempty;
-
-import net.minecraft.world.WorldProvider;
-import net.minecraft.world.chunk.IChunkProvider;
-
-public class WorldProviderEmpty extends WorldProvider
-{
-
- public IChunkProvider createChunkGenerator()
- {
- return new ChunkProviderEmpty(worldObj);
- }
-
- @Override
- public String getDimensionName()
- {
- return "EmptyWorld";
- }
-
-}
+package org.ultramine.server.wempty;
+
+import net.minecraft.world.WorldProvider;
+import net.minecraft.world.chunk.IChunkProvider;
+
+public class WorldProviderEmpty extends WorldProvider
+{
+
+ public IChunkProvider createChunkGenerator()
+ {
+ return new ChunkProviderEmpty(worldObj);
+ }
+
+ @Override
+ public String getDimensionName()
+ {
+ return "EmptyWorld";
+ }
+
+}