mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 04:09:51 +00:00
Cleanup: removed IEEP, removed redundant casts, fixed imports, fixed typos.
This commit is contained in:
1 parent
7e4d7077a5
commit
a9d23f5e78
133 files changed
+489
-623
No files matched your search
@@ -71,8 +71,8 @@ public class BiomeDictionary
|
||||
/**
|
||||
* Retrieves a Type value by name,
|
||||
* if one does not exist already it creates one.
|
||||
* This can be used as interm measure for modders to
|
||||
* add there own category of Biome.
|
||||
* This can be used as intermediate measure for modders to
|
||||
* add their own category of Biome.
|
||||
*
|
||||
* There are NO naming conventions besides:
|
||||
* MUST be all upper case (enforced by name.toUpper())
|
||||
@@ -187,7 +187,7 @@ public class BiomeDictionary
|
||||
{
|
||||
if(typeInfoList[type.ordinal()] != null)
|
||||
{
|
||||
return (BiomeGenBase[])typeInfoList[type.ordinal()].toArray(new BiomeGenBase[0]);
|
||||
return typeInfoList[type.ordinal()].toArray(new BiomeGenBase[0]);
|
||||
}
|
||||
|
||||
return new BiomeGenBase[0];
|
||||
@@ -202,7 +202,7 @@ public class BiomeDictionary
|
||||
public static Type[] getTypesForBiome(BiomeGenBase biome)
|
||||
{
|
||||
checkRegistration(biome);
|
||||
return (Type[])getBiomeInfo(biome).typeList.toArray(new Type[0]);
|
||||
return getBiomeInfo(biome).typeList.toArray(new Type[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -136,7 +136,7 @@ public class DimensionManager
|
||||
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());
|
||||
FMLLog.fine("The world %x (%s) may have leaked: first encounter (5 occurrences).\n", System.identityHashCode(w), w.getWorldInfo().getWorldName());
|
||||
}
|
||||
else if (leakCount % 5 == 0)
|
||||
{
|
||||
@@ -259,7 +259,7 @@ public class DimensionManager
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLCommonHandler.instance().getFMLLogger().log(Level.ERROR, String.format("An error occured trying to create an instance of WorldProvider %d (%s)",
|
||||
FMLCommonHandler.instance().getFMLLogger().log(Level.ERROR, String.format("An error occurred trying to create an instance of WorldProvider %d (%s)",
|
||||
dim, getProviderType(dim)),e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -372,7 +372,7 @@ public class DimensionManager
|
||||
{
|
||||
if (DimensionManager.getWorld(0) != null)
|
||||
{
|
||||
return ((SaveHandler)DimensionManager.getWorld(0).getSaveHandler()).getWorldDirectory();
|
||||
return DimensionManager.getWorld(0).getSaveHandler().getWorldDirectory();
|
||||
}/*
|
||||
else if (MinecraftServer.getServer() != null)
|
||||
{
|
||||
|
||||
@@ -68,7 +68,7 @@ public class DungeonHooks
|
||||
*/
|
||||
public static String getRandomDungeonMob(Random rand)
|
||||
{
|
||||
DungeonMob mob = (DungeonMob)WeightedRandom.getRandomItem(rand, dungeonMobs);
|
||||
DungeonMob mob = WeightedRandom.getRandomItem(rand, dungeonMobs);
|
||||
if (mob == null)
|
||||
{
|
||||
return "";
|
||||
|
||||
@@ -15,10 +15,31 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Iterators;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ClassInheritanceMultiMap;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
@@ -29,6 +50,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.LinkedHashMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.MapMaker;
|
||||
@@ -37,29 +59,6 @@ import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ClassInheritanceMultiMap;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Manages chunkloading for mods.
|
||||
*
|
||||
@@ -422,7 +421,7 @@ public class ForgeChunkManager
|
||||
|
||||
static void loadWorld(World world)
|
||||
{
|
||||
ArrayListMultimap<String, Ticket> newTickets = ArrayListMultimap.<String, Ticket>create();
|
||||
ArrayListMultimap<String, Ticket> newTickets = ArrayListMultimap.create();
|
||||
tickets.put(world, newTickets);
|
||||
|
||||
forcedChunks.put(world, ImmutableSetMultimap.<ChunkCoordIntPair,Ticket>of());
|
||||
@@ -439,7 +438,7 @@ public class ForgeChunkManager
|
||||
|
||||
if (chunkLoaderData.exists() && chunkLoaderData.isFile())
|
||||
{
|
||||
ArrayListMultimap<String, Ticket> loadedTickets = ArrayListMultimap.<String, Ticket>create();
|
||||
ArrayListMultimap<String, Ticket> loadedTickets = ArrayListMultimap.create();
|
||||
Map<String,ListMultimap<String,Ticket>> playerLoadedTickets = Maps.newHashMap();
|
||||
NBTTagCompound forcedChunkData;
|
||||
try
|
||||
@@ -454,7 +453,7 @@ public class ForgeChunkManager
|
||||
NBTTagList ticketList = forcedChunkData.getTagList("TicketList", Constants.NBT.TAG_COMPOUND);
|
||||
for (int i = 0; i < ticketList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound ticketHolder = (NBTTagCompound)ticketList.getCompoundTagAt(i);
|
||||
NBTTagCompound ticketHolder = ticketList.getCompoundTagAt(i);
|
||||
String modId = ticketHolder.getString("Owner");
|
||||
boolean isPlayer = "Forge".equals(modId);
|
||||
|
||||
@@ -473,7 +472,7 @@ public class ForgeChunkManager
|
||||
NBTTagList tickets = ticketHolder.getTagList("Tickets", Constants.NBT.TAG_COMPOUND);
|
||||
for (int j = 0; j < tickets.tagCount(); j++)
|
||||
{
|
||||
NBTTagCompound ticket = (NBTTagCompound) tickets.getCompoundTagAt(j);
|
||||
NBTTagCompound ticket = tickets.getCompoundTagAt(j);
|
||||
modId = ticket.hasKey("ModId") ? ticket.getString("ModId") : modId;
|
||||
Type type = Type.values()[ticket.getByte("Type")];
|
||||
//byte ticketChunkDepth = ticket.getByte("ChunkListDepth");
|
||||
@@ -940,7 +939,7 @@ public class ForgeChunkManager
|
||||
{
|
||||
for (ClassInheritanceMultiMap<Entity> eList : chunk.getEntityLists())
|
||||
{
|
||||
Iterator<Entity> itr = (Iterator<Entity>)eList.iterator();
|
||||
Iterator<Entity> itr = eList.iterator();
|
||||
while (itr.hasNext())
|
||||
{
|
||||
(itr.next()).resetEntityId();
|
||||
@@ -966,7 +965,7 @@ public class ForgeChunkManager
|
||||
dest.delete();
|
||||
}
|
||||
cfgFile.renameTo(dest);
|
||||
FMLLog.log(Level.ERROR, e, "A critical error occured reading the forgeChunkLoading.cfg file, defaults will be used - the invalid file is backed up at forgeChunkLoading.cfg.bak");
|
||||
FMLLog.log(Level.ERROR, e, "A critical error occurred reading the forgeChunkLoading.cfg file, defaults will be used - the invalid file is backed up at forgeChunkLoading.cfg.bak");
|
||||
}
|
||||
syncConfigDefaults();
|
||||
}
|
||||
|
||||
@@ -20,23 +20,15 @@ import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.block.BlockTrapDoor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLeashKnot;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityArmorStand;
|
||||
import net.minecraft.entity.item.EntityBoat;
|
||||
import net.minecraft.entity.item.EntityEnderCrystal;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityItemFrame;
|
||||
import net.minecraft.entity.item.EntityMinecart;
|
||||
import net.minecraft.entity.item.EntityMinecartContainer;
|
||||
import net.minecraft.entity.item.EntityPainting;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -46,18 +38,14 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ContainerRepair;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemAxe;
|
||||
import net.minecraft.item.ItemBucket;
|
||||
import net.minecraft.item.ItemMonsterPlacer;
|
||||
import net.minecraft.item.ItemPickaxe;
|
||||
import net.minecraft.item.ItemSpade;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.SPacketBlockChange;
|
||||
@@ -83,7 +71,6 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.minecraft.world.WorldSettings.GameType;
|
||||
import net.minecraft.world.gen.feature.WorldGeneratorBonusChest;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.event.AnvilUpdateEvent;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
@@ -100,7 +87,6 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
|
||||
import net.minecraftforge.event.entity.player.AnvilRepairEvent;
|
||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.event.world.NoteBlockEvent;
|
||||
@@ -129,7 +115,7 @@ public class ForgeHooks
|
||||
|
||||
public static ItemStack getGrassSeed(Random rand, int fortune)
|
||||
{
|
||||
SeedEntry entry = (SeedEntry)WeightedRandom.getRandomItem(rand, seedList);
|
||||
SeedEntry entry = WeightedRandom.getRandomItem(rand, seedList);
|
||||
if (entry == null || entry.seed == null)
|
||||
{
|
||||
return null;
|
||||
@@ -426,7 +412,7 @@ public class ForgeHooks
|
||||
|
||||
if (target.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
s1 = ((ResourceLocation)Block.blockRegistry.getNameForObject(world.getBlockState(target.getBlockPos()).getBlock())).toString();
|
||||
s1 = Block.blockRegistry.getNameForObject(world.getBlockState(target.getBlockPos()).getBlock()).toString();
|
||||
}
|
||||
else if (target.typeOfHit == RayTraceResult.Type.ENTITY)
|
||||
{
|
||||
@@ -461,7 +447,7 @@ public class ForgeHooks
|
||||
}
|
||||
|
||||
//Optifine Helper Functions u.u, these are here specifically for Optifine
|
||||
//Note: When using Optfine, these methods are invoked using reflection, which
|
||||
//Note: When using Optifine, these methods are invoked using reflection, which
|
||||
//incurs a major performance penalty.
|
||||
public static void onLivingSetAttackTarget(EntityLivingBase entity, EntityLivingBase target)
|
||||
{
|
||||
@@ -481,7 +467,7 @@ public class ForgeHooks
|
||||
public static float onLivingHurt(EntityLivingBase entity, DamageSource src, float amount)
|
||||
{
|
||||
LivingHurtEvent event = new LivingHurtEvent(entity, src, amount);
|
||||
return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.ammount);
|
||||
return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.getAmount());
|
||||
}
|
||||
|
||||
public static boolean onLivingDeath(EntityLivingBase entity, DamageSource src)
|
||||
@@ -568,7 +554,6 @@ public class ForgeHooks
|
||||
return world.getBlockState(pos).getBlock().getEnchantPowerBonus(world, pos);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static ITextComponent onServerChatEvent(NetHandlerPlayServer net, String raw, ITextComponent comp)
|
||||
{
|
||||
ServerChatEvent event = new ServerChatEvent(net.playerEntity, raw, comp);
|
||||
@@ -907,11 +892,11 @@ public class ForgeHooks
|
||||
{
|
||||
filled *= -1;
|
||||
//filled -= 0.11111111F; //Why this is needed.. not sure...
|
||||
return eyes > (double)(pos.getY() + 1 + (1 - filled));
|
||||
return eyes > pos.getY() + 1 + (1 - filled);
|
||||
}
|
||||
else
|
||||
{
|
||||
return eyes < (double)(pos.getY() + 1 + filled);
|
||||
return eyes < pos.getY() + 1 + filled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.event.entity.*;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class ForgeInternalHandler
|
||||
{
|
||||
|
||||
@@ -170,7 +170,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
prop = config.get(CATEGORY_GENERAL, "sortRecipies", true);
|
||||
prop.comment = "Set to true to enable the post initialization sorting of crafting recipes using Forge's sorter. May cause desyncing on conflicting recipies. MUST RESTART MINECRAFT IF CHANGED FROM THE CONFIG GUI.";
|
||||
prop.comment = "Set to true to enable the post initialization sorting of crafting recipes using Forge's sorter. May cause desyncing on conflicting recipes. MUST RESTART MINECRAFT IF CHANGED FROM THE CONFIG GUI.";
|
||||
prop.setLanguageKey("forge.configgui.sortRecipies").setRequiresMcRestart(true);
|
||||
shouldSortRecipies = prop.getBoolean(shouldSortRecipies);
|
||||
propOrder.add(prop.getName());
|
||||
@@ -202,7 +202,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
|
||||
disableStitchedFileSaving = prop.getBoolean(true);
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "fullBoundingBoxLadders", false);
|
||||
prop.comment = "Set this to true to check the entire entity's collision bounding box for ladders instead of just the block they are in. Causes noticable differences in mechanics so default is vanilla behavior. Default: false";
|
||||
prop.comment = "Set this to true to check the entire entity's collision bounding box for ladders instead of just the block they are in. Causes noticeable differences in mechanics so default is vanilla behavior. Default: false";
|
||||
prop.setLanguageKey("forge.configgui.fullBoundingBoxLadders").setRequiresWorldRestart(true);
|
||||
fullBoundingBoxLadders = prop.getBoolean(false);
|
||||
propOrder.add(prop.getName());
|
||||
@@ -226,7 +226,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
|
||||
propOrder.add(prop.getName());
|
||||
|
||||
prop = config.get(Configuration.CATEGORY_GENERAL, "defaultSpawnFuzz", 20,
|
||||
"The spawn fuzz when a player respawns in the world, this is controlable by WorldType, this config option is for the default overworld.",
|
||||
"The spawn fuzz when a player respawns in the world, this is controllable by WorldType, this config option is for the default overworld.",
|
||||
1, Integer.MAX_VALUE);
|
||||
prop.setLanguageKey("forge.configgui.spawnfuzz").setRequiresWorldRestart(false);
|
||||
defaultSpawnFuzz = prop.getInt(20);
|
||||
|
||||
@@ -119,7 +119,7 @@ public class ForgeVersion
|
||||
{
|
||||
if (!ForgeModContainer.getConfig().get(ForgeModContainer.VERSION_CHECK_CAT, "Global", true).getBoolean())
|
||||
{
|
||||
FMLLog.log("ForgeVersionCheck", Level.INFO, "Global Forge version check system disabeld, no futher processing.");
|
||||
FMLLog.log("ForgeVersionCheck", Level.INFO, "Global Forge version check system disabled, no further processing.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Allows for custom entity data and logic to be hooked to existing entity classes.
|
||||
*
|
||||
* @author cpw, mithion
|
||||
*
|
||||
*/
|
||||
public interface IExtendedEntityProperties {
|
||||
/**
|
||||
* Called when the entity that this class is attached to is saved.
|
||||
* Any custom entity data that needs saving should be saved here.
|
||||
* @param compound The compound to save to.
|
||||
*/
|
||||
public void saveNBTData(NBTTagCompound compound);
|
||||
|
||||
/**
|
||||
* Called when the entity that this class is attached to is loaded.
|
||||
* In order to hook into this, you will need to subscribe to the EntityConstructing event.
|
||||
* Otherwise, you will need to initialize manually.
|
||||
* @param compound The compound to load from.
|
||||
*/
|
||||
public void loadNBTData(NBTTagCompound compound);
|
||||
|
||||
/**
|
||||
* Used to initialize the extended properties with the entity that this is attached to, as well
|
||||
* as the world object.
|
||||
* Called automatically if you register with the EntityConstructing event.
|
||||
* May be called multiple times if the extended properties is moved over to a new entity.
|
||||
* Such as when a player switches dimension {Minecraft re-creates the player entity}
|
||||
* @param entity The entity that this extended properties is attached to
|
||||
* @param world The world in which the entity exists
|
||||
*/
|
||||
public void init(Entity entity, World world);
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public interface IMinecartCollisionHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* This basically replaces the function of the same name in EnityMinecart.
|
||||
* This basically replaces the function of the same name in EntityMinecart.
|
||||
* Code in IMinecartHooks.applyEntityCollisionHook is still run.
|
||||
* @param cart The cart that called the collision.
|
||||
* @param other The object it collided with.
|
||||
|
||||
@@ -71,7 +71,7 @@ public interface ISpecialArmor
|
||||
public int AbsorbMax = Integer.MAX_VALUE;
|
||||
public double AbsorbRatio = 0;
|
||||
public int Slot = 0;
|
||||
private static final boolean DEBUG = false; //Only enable this if you wish to be spamed with debugging information.
|
||||
private static final boolean DEBUG = false; //Only enable this if you wish to be spammed with debugging information.
|
||||
//Left it in because I figured it'd be useful for modders developing custom armor.
|
||||
|
||||
public ArmorProperties(int priority, double ratio, int max)
|
||||
|
||||
@@ -44,7 +44,7 @@ public class WorldSpecificSaveHandler implements ISaveHandler
|
||||
@Override
|
||||
public File getMapFileFromName(String name)
|
||||
{
|
||||
if (dataDir == null) //Delayed down here do that world has time to be initalized first.
|
||||
if (dataDir == null) //Delayed down here do that world has time to be initialized first.
|
||||
{
|
||||
dataDir = new File(world.getChunkSaveLocation(), "data");
|
||||
dataDir.mkdirs();
|
||||
@@ -76,7 +76,7 @@ public class WorldSpecificSaveHandler implements ISaveHandler
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log(Level.ERROR, e, "A critical error occured copying %s to world specific dat folder - new file will be created.", parentFile.getName());
|
||||
FMLLog.log(Level.ERROR, e, "A critical error occurred copying %s to world specific dat folder - new file will be created.", parentFile.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class BrewingRecipeRegistry {
|
||||
/**
|
||||
* Returns true if the passed input and ingredient have an output
|
||||
*/
|
||||
public static boolean hasOuput(ItemStack input, ItemStack ingredient)
|
||||
public static boolean hasOutput(ItemStack input, ItemStack ingredient)
|
||||
{
|
||||
return getOutput(input, ingredient) != null;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class BrewingRecipeRegistry {
|
||||
|
||||
for (int i : inputIndexes)
|
||||
{
|
||||
if (hasOuput(inputs[i], ingredient))
|
||||
if (hasOutput(inputs[i], ingredient))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public enum CapabilityManager
|
||||
public T call() throws Exception
|
||||
{
|
||||
try {
|
||||
return (T)implementation.newInstance();
|
||||
return implementation.newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
Throwables.propagate(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
|
||||
@@ -23,12 +23,12 @@ public class ConfigElement implements IConfigElement
|
||||
private Property prop;
|
||||
private Property.Type type;
|
||||
private boolean isProperty;
|
||||
private ConfigCategory ctgy;
|
||||
private ConfigCategory category;
|
||||
private boolean categoriesFirst = true;
|
||||
|
||||
public ConfigElement(ConfigCategory ctgy)
|
||||
public ConfigElement(ConfigCategory category)
|
||||
{
|
||||
this.ctgy = ctgy;
|
||||
this.category = category;
|
||||
isProperty = false;
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ public class ConfigElement implements IConfigElement
|
||||
if (!isProperty)
|
||||
{
|
||||
List<IConfigElement> elements = new ArrayList<IConfigElement>();
|
||||
Iterator<ConfigCategory> ccI = ctgy.getChildren().iterator();
|
||||
Iterator<Property> pI = ctgy.getOrderedValues().iterator();
|
||||
Iterator<ConfigCategory> ccI = category.getChildren().iterator();
|
||||
Iterator<Property> pI = category.getOrderedValues().iterator();
|
||||
@SuppressWarnings("unused")
|
||||
int index = 0;
|
||||
|
||||
@@ -87,7 +87,7 @@ public class ConfigElement implements IConfigElement
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return isProperty ? prop.getName() : ctgy.getName();
|
||||
return isProperty ? prop.getName() : category.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,7 +99,7 @@ public class ConfigElement implements IConfigElement
|
||||
@Override
|
||||
public Class<? extends IConfigEntry> getConfigEntryClass()
|
||||
{
|
||||
return isProperty ? prop.getConfigEntryClass() : ctgy.getConfigEntryClass();
|
||||
return isProperty ? prop.getConfigEntryClass() : category.getConfigEntryClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,7 +111,7 @@ public class ConfigElement implements IConfigElement
|
||||
@Override
|
||||
public String getQualifiedName()
|
||||
{
|
||||
return isProperty ? prop.getName() : ctgy.getQualifiedName();
|
||||
return isProperty ? prop.getName() : category.getQualifiedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,7 +148,7 @@ public class ConfigElement implements IConfigElement
|
||||
@Override
|
||||
public String getComment()
|
||||
{
|
||||
return isProperty ? prop.comment : ctgy.getComment();
|
||||
return isProperty ? prop.comment : category.getComment();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -167,19 +167,19 @@ public class ConfigElement implements IConfigElement
|
||||
@Override
|
||||
public boolean requiresWorldRestart()
|
||||
{
|
||||
return isProperty ? prop.requiresWorldRestart() : ctgy.requiresWorldRestart();
|
||||
return isProperty ? prop.requiresWorldRestart() : category.requiresWorldRestart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInGui()
|
||||
{
|
||||
return isProperty ? prop.showInGui() : ctgy.showInGui();
|
||||
return isProperty ? prop.showInGui() : category.showInGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresMcRestart()
|
||||
{
|
||||
return isProperty ? prop.requiresMcRestart() : ctgy.requiresMcRestart();
|
||||
return isProperty ? prop.requiresMcRestart() : category.requiresMcRestart();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -191,7 +191,7 @@ public class ConfigElement implements IConfigElement
|
||||
@Override
|
||||
public String getLanguageKey()
|
||||
{
|
||||
return isProperty ? prop.getLanguageKey() : ctgy.getLanguagekey();
|
||||
return isProperty ? prop.getLanguageKey() : category.getLanguagekey();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -166,7 +166,7 @@ public class Configuration
|
||||
*/
|
||||
public Property get(String category, String key, boolean defaultValue)
|
||||
{
|
||||
return get(category, key, defaultValue, (String) null);
|
||||
return get(category, key, defaultValue, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,7 +201,7 @@ public class Configuration
|
||||
*/
|
||||
public Property get(String category, String key, boolean[] defaultValues)
|
||||
{
|
||||
return get(category, key, defaultValues, (String) null);
|
||||
return get(category, key, defaultValues, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,7 +268,7 @@ public class Configuration
|
||||
*/
|
||||
public Property get(String category, String key, int defaultValue)
|
||||
{
|
||||
return get(category, key, defaultValue, (String) null, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
return get(category, key, defaultValue, null, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,7 +321,7 @@ public class Configuration
|
||||
*/
|
||||
public Property get(String category, String key, int[] defaultValues)
|
||||
{
|
||||
return get(category, key, defaultValues, (String) null);
|
||||
return get(category, key, defaultValues, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -410,7 +410,7 @@ public class Configuration
|
||||
*/
|
||||
public Property get(String category, String key, double defaultValue)
|
||||
{
|
||||
return get(category, key, defaultValue, (String) null);
|
||||
return get(category, key, defaultValue, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -553,7 +553,7 @@ public class Configuration
|
||||
*/
|
||||
public Property get(String category, String key, String defaultValue)
|
||||
{
|
||||
return get(category, key, defaultValue, (String) null);
|
||||
return get(category, key, defaultValue, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -615,7 +615,7 @@ public class Configuration
|
||||
*/
|
||||
public Property get(String category, String key, String[] defaultValues)
|
||||
{
|
||||
return get(category, key, defaultValues, (String) null, false, -1, (Pattern) null);
|
||||
return get(category, key, defaultValues, null, false, -1, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -629,7 +629,7 @@ public class Configuration
|
||||
*/
|
||||
public Property get(String category, String key, String[] defaultValues, String comment)
|
||||
{
|
||||
return get(category, key, defaultValues, comment, false, -1, (Pattern) null);
|
||||
return get(category, key, defaultValues, comment, false, -1, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -877,7 +877,7 @@ public class Configuration
|
||||
}
|
||||
else if (Character.isWhitespace(line.charAt(i)))
|
||||
{
|
||||
// ignore space charaters
|
||||
// ignore space characters
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -927,7 +927,7 @@ public class Configuration
|
||||
break;
|
||||
if (currentCat == null)
|
||||
{
|
||||
throw new RuntimeException(String.format("Config file corrupt, attepted to close to many categories '%s:%d'", fileName, lineNum));
|
||||
throw new RuntimeException(String.format("Config file corrupt, attempted to close to many categories '%s:%d'", fileName, lineNum));
|
||||
}
|
||||
currentCat = currentCat.parent;
|
||||
break;
|
||||
@@ -1330,7 +1330,7 @@ public class Configuration
|
||||
size = 4;
|
||||
}
|
||||
else if (bom32 == 0xFFFE0000) //This will never happen as it'll be caught by UTF-16LE,
|
||||
{ //but if anyone ever runs across a 32LE file, i'd like to disect it.
|
||||
{ //but if anyone ever runs across a 32LE file, i'd like to dissect it.
|
||||
enc = "UTF-32LE";
|
||||
size = 4;
|
||||
}
|
||||
@@ -1567,7 +1567,7 @@ public class Configuration
|
||||
*/
|
||||
public String[] getStringList(String name, String category, String[] defaultValues, String comment)
|
||||
{
|
||||
return getStringList(name, category, defaultValues, comment, (String[]) null, name);
|
||||
return getStringList(name, category, defaultValues, comment, null, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,7 @@ import com.google.common.collect.Maps;
|
||||
* If created with matrix, should successfully decompose it to a composition
|
||||
* of easily interpolatable transformations (translation, first rotation, scale
|
||||
* (with generally speaking different factors for each axis) and second rotation.
|
||||
* If the inpit matrix is a composition of translation, rotation and scale (in
|
||||
* If the input matrix is a composition of translation, rotation and scale (in
|
||||
* any order), then the interpolation of the derived primitive transformations
|
||||
* should result in the same transformation as the interpolation of the originals.
|
||||
* Decomposition happens lazily (and is hopefully fast enough), so performance
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ExtendedBlockState extends BlockStateContainer
|
||||
public ExtendedBlockState(Block blockIn, IProperty<?>[] properties, IUnlistedProperty<?>[] unlistedProperties)
|
||||
{
|
||||
super(blockIn, properties, buildUnlistedMap(unlistedProperties));
|
||||
ImmutableSet.Builder<IUnlistedProperty<?>> builder = ImmutableSet.<IUnlistedProperty<?>>builder();
|
||||
ImmutableSet.Builder<IUnlistedProperty<?>> builder = ImmutableSet.builder();
|
||||
for(IUnlistedProperty<?> property : unlistedProperties)
|
||||
{
|
||||
builder.add(property);
|
||||
@@ -40,7 +40,7 @@ public class ExtendedBlockState extends BlockStateContainer
|
||||
|
||||
private static ImmutableMap<IUnlistedProperty<?>, Optional<?>> buildUnlistedMap(IUnlistedProperty<?>[] unlistedProperties)
|
||||
{
|
||||
ImmutableMap.Builder<IUnlistedProperty<?>, Optional<?>> builder = ImmutableMap.<IUnlistedProperty<?>, Optional<?>>builder();
|
||||
ImmutableMap.Builder<IUnlistedProperty<?>, Optional<?>> builder = ImmutableMap.builder();
|
||||
for(IUnlistedProperty<?> p : unlistedProperties)
|
||||
{
|
||||
builder.put(p, Optional.absent());
|
||||
@@ -74,25 +74,27 @@ public class ExtendedBlockState extends BlockStateContainer
|
||||
{
|
||||
throw new IllegalArgumentException("Cannot set property " + property + " as it does not exist in " + getBlock().getBlockState());
|
||||
}
|
||||
else if (!property.getAllowedValues().contains(value))
|
||||
{
|
||||
throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on block " + Block.blockRegistry.getNameForObject(getBlock()) + ", it is not an allowed value");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.getProperties().get(property) == value)
|
||||
if (!property.getAllowedValues().contains(value))
|
||||
{
|
||||
return this;
|
||||
throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on block " + Block.blockRegistry.getNameForObject(getBlock()) + ", it is not an allowed value");
|
||||
} else
|
||||
{
|
||||
if (this.getProperties().get(property) == value)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
Map<IProperty<?>, Comparable<?>> map = Maps.newHashMap(getProperties());
|
||||
map.put(property, value);
|
||||
if (Iterables.all(unlistedProperties.values(), Predicates.<Optional<?>>equalTo(Optional.absent())))
|
||||
{ // no dynamic properties present, looking up in the normal table
|
||||
return normalMap.get(map);
|
||||
}
|
||||
ImmutableTable<IProperty<?>, Comparable<?>, IBlockState> table = propertyValueTable;
|
||||
table = ((StateImplementation) table.get(property, value)).getPropertyValueTable();
|
||||
return new ExtendedStateImplementation(getBlock(), ImmutableMap.copyOf(map), unlistedProperties, table).setMap(this.normalMap);
|
||||
}
|
||||
Map<IProperty<?>, Comparable<?>> map = Maps.newHashMap(getProperties());
|
||||
map.put(property, value);
|
||||
if(Iterables.all(unlistedProperties.values(), Predicates.<Optional<?>>equalTo(Optional.absent())))
|
||||
{ // no dynamic properties present, looking up in the normal table
|
||||
return (IExtendedBlockState) normalMap.get(map);
|
||||
}
|
||||
ImmutableTable<IProperty<?>, Comparable<?>, IBlockState> table = propertyValueTable;
|
||||
table = ((StateImplementation)table.get(property, value)).getPropertyValueTable();
|
||||
return new ExtendedStateImplementation(getBlock(), ImmutableMap.copyOf(map), unlistedProperties, table).setMap(this.normalMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,28 +57,27 @@ public final class AsynchronousExecutor<P, T, C, E extends Throwable> {
|
||||
void callStage3(P parameter, T object, C callback) throws E;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
static final AtomicIntegerFieldUpdater STATE_FIELD = AtomicIntegerFieldUpdater.newUpdater(AsynchronousExecutor.Task.class, "state");
|
||||
private static class StateHolder {
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private static boolean set(AsynchronousExecutor.Task $this, int expected, int value) {
|
||||
return STATE_FIELD.compareAndSet($this, expected, value);
|
||||
protected static final int PENDING = 0x0;
|
||||
protected static final int STAGE_1_ASYNC = PENDING + 1;
|
||||
protected static final int STAGE_1_SYNC = STAGE_1_ASYNC + 1;
|
||||
protected static final int STAGE_1_COMPLETE = STAGE_1_SYNC + 1;
|
||||
protected static final int FINISHED = STAGE_1_COMPLETE + 1;
|
||||
|
||||
protected volatile int state = PENDING;
|
||||
|
||||
protected static final AtomicIntegerFieldUpdater<StateHolder> STATE = AtomicIntegerFieldUpdater.newUpdater(StateHolder.class, "state");
|
||||
}
|
||||
|
||||
class Task implements Runnable {
|
||||
static final int PENDING = 0x0;
|
||||
static final int STAGE_1_ASYNC = PENDING + 1;
|
||||
static final int STAGE_1_SYNC = STAGE_1_ASYNC + 1;
|
||||
static final int STAGE_1_COMPLETE = STAGE_1_SYNC + 1;
|
||||
static final int FINISHED = STAGE_1_COMPLETE + 1;
|
||||
private class Task extends StateHolder implements Runnable {
|
||||
|
||||
volatile int state = PENDING;
|
||||
final P parameter;
|
||||
T object;
|
||||
final List<C> callbacks = new LinkedList<C>();
|
||||
E t = null;
|
||||
private final P parameter;
|
||||
private T object;
|
||||
private final List<C> callbacks = new LinkedList<C>();
|
||||
private E t = null;
|
||||
|
||||
Task(final P parameter) {
|
||||
private Task(final P parameter) {
|
||||
this.parameter = parameter;
|
||||
}
|
||||
|
||||
@@ -88,14 +87,14 @@ public final class AsynchronousExecutor<P, T, C, E extends Throwable> {
|
||||
}
|
||||
}
|
||||
|
||||
boolean initAsync() {
|
||||
if (set(this, PENDING, STAGE_1_ASYNC)) {
|
||||
private boolean initAsync() {
|
||||
if (STATE.compareAndSet(this, PENDING, STAGE_1_ASYNC)) {
|
||||
boolean ret = true;
|
||||
|
||||
try {
|
||||
init();
|
||||
} finally {
|
||||
if (set(this, STAGE_1_ASYNC, STAGE_1_COMPLETE)) {
|
||||
if (STATE.compareAndSet(this, STAGE_1_ASYNC, STAGE_1_COMPLETE)) {
|
||||
// No one is/will be waiting
|
||||
} else {
|
||||
// We know that the sync thread will be waiting
|
||||
@@ -119,14 +118,14 @@ public final class AsynchronousExecutor<P, T, C, E extends Throwable> {
|
||||
}
|
||||
}
|
||||
|
||||
void initSync() {
|
||||
if (set(this, PENDING, STAGE_1_COMPLETE)) {
|
||||
private void initSync() {
|
||||
if (STATE.compareAndSet(this, PENDING, STAGE_1_COMPLETE)) {
|
||||
// If we succeed that variable switch, good as done
|
||||
init();
|
||||
} else if (set(this, STAGE_1_ASYNC, STAGE_1_SYNC)) {
|
||||
} else if (STATE.compareAndSet(this, STAGE_1_ASYNC, STAGE_1_SYNC)) {
|
||||
// Async thread is running, but this shouldn't be likely; we need to sync to wait on them because of it.
|
||||
synchronized (this) {
|
||||
if (set(this, STAGE_1_SYNC, PENDING)) { // They might NOT synchronized yet, atomic lock IS needed
|
||||
if (STATE.compareAndSet(this, STAGE_1_SYNC, PENDING)) { // They might NOT synchronized yet, atomic lock IS needed
|
||||
// We are the first into the lock
|
||||
while (state != STAGE_1_COMPLETE) {
|
||||
try {
|
||||
@@ -146,7 +145,7 @@ public final class AsynchronousExecutor<P, T, C, E extends Throwable> {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
void init() {
|
||||
private void init() {
|
||||
try {
|
||||
object = provider.callStage1(parameter);
|
||||
} catch (final Throwable t) {
|
||||
@@ -155,7 +154,7 @@ public final class AsynchronousExecutor<P, T, C, E extends Throwable> {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
T get() throws E {
|
||||
private T get() throws E {
|
||||
initSync();
|
||||
if (callbacks.isEmpty()) {
|
||||
// 'this' is a placeholder to prevent callbacks from being empty during finish call
|
||||
@@ -166,7 +165,7 @@ public final class AsynchronousExecutor<P, T, C, E extends Throwable> {
|
||||
return object;
|
||||
}
|
||||
|
||||
void finish() throws E {
|
||||
private void finish() throws E {
|
||||
switch (state) {
|
||||
default:
|
||||
case PENDING:
|
||||
@@ -203,8 +202,8 @@ public final class AsynchronousExecutor<P, T, C, E extends Throwable> {
|
||||
}
|
||||
}
|
||||
|
||||
boolean drop() {
|
||||
if (set(this, PENDING, FINISHED)) {
|
||||
private boolean drop() {
|
||||
if (STATE.compareAndSet(this, PENDING, FINISHED)) {
|
||||
// If we succeed that variable switch, good as forgotten
|
||||
tasks.remove(parameter);
|
||||
return true;
|
||||
@@ -215,10 +214,10 @@ public final class AsynchronousExecutor<P, T, C, E extends Throwable> {
|
||||
}
|
||||
}
|
||||
|
||||
final CallBackProvider<P, T, C, E> provider;
|
||||
final Queue<Task> finished = new ConcurrentLinkedQueue<Task>();
|
||||
final Map<P, Task> tasks = new HashMap<P, Task>();
|
||||
final ThreadPoolExecutor pool;
|
||||
private final CallBackProvider<P, T, C, E> provider;
|
||||
private final Queue<Task> finished = new ConcurrentLinkedQueue<Task>();
|
||||
private final Map<P, Task> tasks = new HashMap<P, Task>();
|
||||
private final ThreadPoolExecutor pool;
|
||||
|
||||
/**
|
||||
* Uses a thread pool to pass executions to the provider.
|
||||
@@ -314,7 +313,7 @@ public final class AsynchronousExecutor<P, T, C, E extends Throwable> {
|
||||
/**
|
||||
* Processes a parameter as if it was in the queue, without ever passing to another thread.
|
||||
*/
|
||||
public T getSkipQueue(P parameter, @SuppressWarnings("unchecked")C... callbacks) throws E {
|
||||
public T getSkipQueue(P parameter, C... callbacks) throws E {
|
||||
final CallBackProvider<P, T, C, E> provider = this.provider;
|
||||
final T object = skipQueue(parameter);
|
||||
for (C callback : callbacks) {
|
||||
|
||||
@@ -79,12 +79,12 @@ public class BlockSnapshot implements Serializable
|
||||
/**
|
||||
* Raw constructor designed for serialization usages.
|
||||
*/
|
||||
public BlockSnapshot(int dimension, BlockPos pos, String modid, String blockName, int meta, int flag, NBTTagCompound nbt)
|
||||
public BlockSnapshot(int dimension, BlockPos pos, String modId, String blockName, int meta, int flag, NBTTagCompound nbt)
|
||||
{
|
||||
this.dimId = dimension;
|
||||
this.pos = pos.getImmutable();
|
||||
this.flag = flag;
|
||||
this.blockIdentifier = new UniqueIdentifier(modid + ":" + blockName);
|
||||
this.blockIdentifier = new UniqueIdentifier(modId + ":" + blockName);
|
||||
this.meta = meta;
|
||||
this.nbt = nbt;
|
||||
}
|
||||
|
||||
@@ -35,8 +35,7 @@ public class EnumHelper
|
||||
private static boolean isSetup = false;
|
||||
|
||||
//Some enums are decompiled with extra arguments, so lets check for that
|
||||
@SuppressWarnings("rawtypes")
|
||||
private static Class[][] commonTypes =
|
||||
private static Class<?>[][] commonTypes =
|
||||
{
|
||||
{EnumAction.class},
|
||||
{ArmorMaterial.class, String.class, int.class, int[].class, int.class, SoundEvent.class},
|
||||
@@ -69,8 +68,7 @@ public class EnumHelper
|
||||
{
|
||||
return addEnum(EnumCreatureAttribute.class, name);
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static EnumCreatureType addCreatureType(String name, Class typeClass, int maxNumber, Material material, boolean peaceful, boolean animal)
|
||||
public static EnumCreatureType addCreatureType(String name, Class<?> typeClass, int maxNumber, Material material, boolean peaceful, boolean animal)
|
||||
{
|
||||
return addEnum(EnumCreatureType.class, name, typeClass, maxNumber, material, peaceful, animal);
|
||||
}
|
||||
@@ -147,11 +145,11 @@ public class EnumHelper
|
||||
|
||||
private static < T extends Enum<? >> T makeEnum(Class<T> enumClass, String value, int ordinal, Class<?>[] additionalTypes, Object[] additionalValues) throws Exception
|
||||
{
|
||||
Object[] parms = new Object[additionalValues.length + 2];
|
||||
parms[0] = value;
|
||||
parms[1] = Integer.valueOf(ordinal);
|
||||
System.arraycopy(additionalValues, 0, parms, 2, additionalValues.length);
|
||||
return enumClass.cast(newInstance.invoke(getConstructorAccessor(enumClass, additionalTypes), new Object[] {parms}));
|
||||
Object[] params = new Object[additionalValues.length + 2];
|
||||
params[0] = value;
|
||||
params[1] = ordinal;
|
||||
System.arraycopy(additionalValues, 0, params, 2, additionalValues.length);
|
||||
return enumClass.cast(newInstance.invoke(getConstructorAccessor(enumClass, additionalTypes), new Object[] {params}));
|
||||
}
|
||||
|
||||
public static void setFailsafeFieldValue(Field field, Object target, Object value) throws Exception
|
||||
@@ -189,10 +187,9 @@ public class EnumHelper
|
||||
return addEnum(commonTypes, enumType, enumName, paramValues);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static <T extends Enum<? >> T addEnum(Class[][] map, Class<T> enumType, String enumName, Object... paramValues)
|
||||
public static <T extends Enum<? >> T addEnum(Class<?>[][] map, Class<T> enumType, String enumName, Object... paramValues)
|
||||
{
|
||||
for (Class[] lookup : map)
|
||||
for (Class<?>[] lookup : map)
|
||||
{
|
||||
if (lookup[0] == enumType)
|
||||
{
|
||||
@@ -335,7 +332,7 @@ public class EnumHelper
|
||||
{
|
||||
T[] previousValues = (T[])valuesField.get(enumType);
|
||||
List<T> values = new ArrayList<T>(Arrays.asList(previousValues));
|
||||
T newValue = (T)makeEnum(enumType, enumName, values.size(), paramTypes, paramValues);
|
||||
T newValue = makeEnum(enumType, enumName, values.size(), paramTypes, paramValues);
|
||||
values.add(newValue);
|
||||
setFailsafeFieldValue(valuesField, null, values.toArray((T[]) Array.newInstance(enumType, 0)));
|
||||
cleanEnumCache(enumType);
|
||||
|
||||
@@ -26,16 +26,16 @@ public class JsonUtils
|
||||
public ImmutableList<?> deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException
|
||||
{
|
||||
final Type[] typeArguments = ((ParameterizedType) type).getActualTypeArguments();
|
||||
final Type parameterizedType = listOf(typeArguments[0]).getType();
|
||||
final List<?> list = context.deserialize(json, parameterizedType);
|
||||
final Type parametrizedType = listOf(typeArguments[0]).getType();
|
||||
final List<?> list = context.deserialize(json, parametrizedType);
|
||||
return ImmutableList.copyOf(list);
|
||||
}
|
||||
|
||||
public JsonElement serialize(ImmutableList<?> src, Type type, JsonSerializationContext context)
|
||||
{
|
||||
final Type[] typeArguments = ((ParameterizedType) type).getActualTypeArguments();
|
||||
final Type parameterizedType = listOf(typeArguments[0]).getType();
|
||||
return context.serialize(src, parameterizedType);
|
||||
final Type parametrizedType = listOf(typeArguments[0]).getType();
|
||||
return context.serialize(src, parametrizedType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user