diff --git a/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java b/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java index e8b450a10..fa0d258a2 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java @@ -19,9 +19,9 @@ public class SoundEvent extends Event public static class SoundSourceEvent extends SoundEvent { - public final ISound sound; - public final String uuid; - public final String name; + private final ISound sound; + private final String uuid; + private final String name; public SoundSourceEvent(SoundManager manager, ISound sound, String uuid) { @@ -30,5 +30,20 @@ public class SoundEvent extends Event this.sound = sound; this.uuid = uuid; } + + public ISound getSound() + { + return sound; + } + + public String getUuid() + { + return uuid; + } + + public String getName() + { + return name; + } } } diff --git a/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java b/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java index ea7b56446..7acae4795 100644 --- a/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java +++ b/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java @@ -749,7 +749,7 @@ public class ForgeBlockStateV1 extends Marker public static class TRSRDeserializer implements JsonDeserializer { - public static TRSRDeserializer INSTANCE = new TRSRDeserializer(); + public static final TRSRDeserializer INSTANCE = new TRSRDeserializer(); public TRSRTransformation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { diff --git a/src/main/java/net/minecraftforge/client/model/ModelLoader.java b/src/main/java/net/minecraftforge/client/model/ModelLoader.java index e0c2d064d..1800dda33 100644 --- a/src/main/java/net/minecraftforge/client/model/ModelLoader.java +++ b/src/main/java/net/minecraftforge/client/model/ModelLoader.java @@ -841,8 +841,8 @@ public final class ModelLoader extends ModelBakery */ public static final class White extends TextureAtlasSprite { - public static ResourceLocation LOCATION = new ResourceLocation("white"); - public static White INSTANCE = new White(); + public static final ResourceLocation LOCATION = new ResourceLocation("white"); + public static final White INSTANCE = new White(); private White() { diff --git a/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java b/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java index e8cde42cd..d65b4f208 100644 --- a/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java +++ b/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java @@ -511,7 +511,7 @@ public class B3DModel public static class Texture { - public static Texture White = new Texture("builtin/white", 0, 0, new Vector2f(0, 0), new Vector2f(1, 1), 0); + public static final Texture White = new Texture("builtin/white", 0, 0, new Vector2f(0, 0), new Vector2f(1, 1), 0); private final String path; private final int flags; private final int blend; diff --git a/src/main/java/net/minecraftforge/common/ForgeChunkManager.java b/src/main/java/net/minecraftforge/common/ForgeChunkManager.java index 66d7f7d11..c402b1eaa 100644 --- a/src/main/java/net/minecraftforge/common/ForgeChunkManager.java +++ b/src/main/java/net/minecraftforge/common/ForgeChunkManager.java @@ -1003,37 +1003,37 @@ public class ForgeChunkManager .setCategoryRequiresWorldRestart("defaults", true); Property temp = config.get("defaults", "enabled", true); - temp.comment = "Are mod overrides enabled?"; + temp.setComment("Are mod overrides enabled?"); temp.setLanguageKey("forge.configgui.enableModOverrides"); overridesEnabled = temp.getBoolean(true); propOrder.add("enabled"); temp = config.get("defaults", "maximumChunksPerTicket", 25); - temp.comment = "The default maximum number of chunks a mod can force, per ticket, \n" + - "for a mod without an override. This is the maximum number of chunks a single ticket can force."; + temp.setComment("The default maximum number of chunks a mod can force, per ticket, \n" + + "for a mod without an override. This is the maximum number of chunks a single ticket can force."); temp.setLanguageKey("forge.configgui.maximumChunksPerTicket"); temp.setMinValue(0); defaultMaxChunks = temp.getInt(25); propOrder.add("maximumChunksPerTicket"); temp = config.get("defaults", "maximumTicketCount", 200); - temp.comment = "The default maximum ticket count for a mod which does not have an override\n" + - "in this file. This is the number of chunk loading requests a mod is allowed to make."; + temp.setComment("The default maximum ticket count for a mod which does not have an override\n" + + "in this file. This is the number of chunk loading requests a mod is allowed to make."); temp.setLanguageKey("forge.configgui.maximumTicketCount"); temp.setMinValue(0); defaultMaxCount = temp.getInt(200); propOrder.add("maximumTicketCount"); temp = config.get("defaults", "playerTicketCount", 500); - temp.comment = "The number of tickets a player can be assigned instead of a mod. This is shared across all mods and it is up to the mods to use it."; + temp.setComment("The number of tickets a player can be assigned instead of a mod. This is shared across all mods and it is up to the mods to use it."); temp.setLanguageKey("forge.configgui.playerTicketCount"); temp.setMinValue(0); playerTicketLength = temp.getInt(500); propOrder.add("playerTicketCount"); temp = config.get("defaults", "dormantChunkCacheSize", 0); - temp.comment = "Unloaded chunks can first be kept in a dormant cache for quicker\n" + - "loading times. Specify the size (in chunks) of that cache here"; + temp.setComment("Unloaded chunks can first be kept in a dormant cache for quicker\n" + + "loading times. Specify the size (in chunks) of that cache here"); temp.setLanguageKey("forge.configgui.dormantChunkCacheSize"); temp.setMinValue(0); dormantChunkCacheSize = temp.getInt(0); @@ -1048,9 +1048,9 @@ public class ForgeChunkManager "for that mod"); temp = config.get("Forge", "maximumTicketCount", 200); - temp.comment = "Maximum ticket count for the mod. Zero disables chunkloading capabilities."; + temp.setComment("Maximum ticket count for the mod. Zero disables chunkloading capabilities."); temp = config.get("Forge", "maximumChunksPerTicket", 25); - temp.comment = "Maximum chunks per ticket for the mod."; + temp.setComment("Maximum chunks per ticket for the mod."); for (String mod : config.getCategoryNames()) { if (mod.equals("Forge") || mod.equals("defaults")) diff --git a/src/main/java/net/minecraftforge/common/ForgeHooks.java b/src/main/java/net/minecraftforge/common/ForgeHooks.java index 1a475e054..a58281933 100644 --- a/src/main/java/net/minecraftforge/common/ForgeHooks.java +++ b/src/main/java/net/minecraftforge/common/ForgeHooks.java @@ -777,15 +777,15 @@ public class ForgeHooks for (BlockSnapshot snap : blockSnapshots) { - int updateFlag = snap.flag; - IBlockState oldBlock = snap.replacedBlock; - IBlockState newBlock = world.getBlockState(snap.pos); + int updateFlag = snap.getFlag(); + IBlockState oldBlock = snap.getReplacedBlock(); + IBlockState newBlock = world.getBlockState(snap.getPos()); if (newBlock != null && !(newBlock.getBlock().hasTileEntity(newBlock))) // Containers get placed automatically { - newBlock.getBlock().onBlockAdded(world, snap.pos, newBlock); + newBlock.getBlock().onBlockAdded(world, snap.getPos(), newBlock); } - world.markAndNotifyBlock(snap.pos, null, oldBlock, newBlock, updateFlag); + world.markAndNotifyBlock(snap.getPos(), null, oldBlock, newBlock, updateFlag); } player.addStat(StatList.func_188060_a(itemstack.getItem())); } diff --git a/src/main/java/net/minecraftforge/common/ForgeModContainer.java b/src/main/java/net/minecraftforge/common/ForgeModContainer.java index cf4dd7722..d4a61a4ad 100644 --- a/src/main/java/net/minecraftforge/common/ForgeModContainer.java +++ b/src/main/java/net/minecraftforge/common/ForgeModContainer.java @@ -149,7 +149,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC Property prop; prop = config.get(CATEGORY_GENERAL, "disableVersionCheck", false); - prop.comment = "Set to true to disable Forge's version check mechanics. Forge queries a small json file on our server for version information. For more details see the ForgeVersion class in our github."; + prop.setComment("Set to true to disable Forge's version check mechanics. Forge queries a small json file on our server for version information. For more details see the ForgeVersion class in our github."); // Language keys are a good idea to implement if you are using config GUIs. This allows you to use a .lang file that will hold the // "pretty" version of the property name as well as allow others to provide their own localizations. // This language key is also used to get the tooltip for a property. The tooltip language key is langKey + ".tooltip". @@ -170,13 +170,13 @@ 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 recipes. MUST RESTART MINECRAFT IF CHANGED FROM THE CONFIG GUI."; + prop.setComment("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()); prop = config.get(Configuration.CATEGORY_GENERAL, "removeErroringEntities", false); - prop.comment = "Set this to true to remove any Entity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES."; + prop.setComment("Set this to true to remove any Entity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES."); prop.setLanguageKey("forge.configgui.removeErroringEntities").setRequiresWorldRestart(true); removeErroringEntities = prop.getBoolean(false); propOrder.add(prop.getName()); @@ -187,7 +187,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC } prop = config.get(Configuration.CATEGORY_GENERAL, "removeErroringTileEntities", false); - prop.comment = "Set this to true to remove any TileEntity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES."; + prop.setComment("Set this to true to remove any TileEntity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES."); prop.setLanguageKey("forge.configgui.removeErroringTileEntities").setRequiresWorldRestart(true); removeErroringTileEntities = prop.getBoolean(false); propOrder.add(prop.getName()); @@ -198,17 +198,17 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC } prop = config.get(Configuration.CATEGORY_GENERAL, "disableStitchedFileSaving", true); - prop.comment = "Set this to just disable the texture stitcher from writing the '{name}_{mipmap}.png files to disc. Just a small performance tweak. Default: true"; + prop.setComment("Set this to just disable the texture stitcher from writing the '{name}_{mipmap}.png files to disc. Just a small performance tweak. Default: true"); disableStitchedFileSaving = prop.getBoolean(true); prop = config.get(Configuration.CATEGORY_GENERAL, "fullBoundingBoxLadders", false); - prop.comment = "Set this to 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.setComment("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()); prop = config.get(Configuration.CATEGORY_GENERAL, "biomeSkyBlendRange", new int[] { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34 }); - prop.comment = "Control the range of sky blending for colored skies in biomes."; + prop.setComment("Control the range of sky blending for colored skies in biomes."); prop.setLanguageKey("forge.configgui.biomeSkyBlendRange"); blendRanges = prop.getIntList(); propOrder.add(prop.getName()); @@ -274,18 +274,18 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC @SubscribeEvent public void onConfigChanged(OnConfigChangedEvent event) { - if (getMetadata().modId.equals(event.modID) && !event.isWorldRunning) + if (getMetadata().modId.equals(event.getModID()) && !event.isWorldRunning()) { - if (Configuration.CATEGORY_GENERAL.equals(event.configID)) + if (Configuration.CATEGORY_GENERAL.equals(event.getConfigID())) { syncConfig(false); } - else if ("chunkLoader".equals(event.configID)) + else if ("chunkLoader".equals(event.getConfigID())) { ForgeChunkManager.syncConfigDefaults(); ForgeChunkManager.loadConfiguration(); } - else if (VERSION_CHECK_CAT.equals(event.configID)) + else if (VERSION_CHECK_CAT.equals(event.getConfigID())) { syncConfig(false); } diff --git a/src/main/java/net/minecraftforge/common/brewing/AbstractBrewingRecipe.java b/src/main/java/net/minecraftforge/common/brewing/AbstractBrewingRecipe.java index ceb3dd15a..278abffbb 100644 --- a/src/main/java/net/minecraftforge/common/brewing/AbstractBrewingRecipe.java +++ b/src/main/java/net/minecraftforge/common/brewing/AbstractBrewingRecipe.java @@ -5,9 +5,9 @@ import net.minecraftforge.oredict.OreDictionary; public abstract class AbstractBrewingRecipe implements IBrewingRecipe { - public final ItemStack input; - public final T ingredient; - public final ItemStack output; + private final ItemStack input; + private final T ingredient; + private final ItemStack output; protected AbstractBrewingRecipe(ItemStack input, T ingredient, ItemStack output) { @@ -15,12 +15,12 @@ public abstract class AbstractBrewingRecipe implements IBrewingRecipe { this.ingredient = ingredient; this.output = output; - if (this.input == null || this.ingredient == null || this.output == null) + if (this.getInput() == null || this.getIngredient() == null || this.getOutput() == null) { throw new IllegalArgumentException("A brewing recipe cannot have a null parameter."); } - if (this.input.getMaxStackSize() != 1) + if (this.getInput().getMaxStackSize() != 1) { throw new IllegalArgumentException("Inputs must have a max size of 1 just like water bottles. Brewing Stands override the input with the output when the brewing is done, items that stack would end up getting lost."); } @@ -29,12 +29,27 @@ public abstract class AbstractBrewingRecipe implements IBrewingRecipe { @Override public boolean isInput(ItemStack stack) { - return OreDictionary.itemMatches(this.input, stack, false); + return OreDictionary.itemMatches(this.getInput(), stack, false); } @Override public ItemStack getOutput(ItemStack input, ItemStack ingredient) { - return isInput(input) && isIngredient(ingredient) ? ItemStack.copyItemStack(output) : null; + return isInput(input) && isIngredient(ingredient) ? ItemStack.copyItemStack(getOutput()) : null; + } + + public ItemStack getInput() + { + return input; + } + + public T getIngredient() + { + return ingredient; + } + + public ItemStack getOutput() + { + return output; } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/brewing/BrewingOreRecipe.java b/src/main/java/net/minecraftforge/common/brewing/BrewingOreRecipe.java index 8ac625cb9..57bd51128 100644 --- a/src/main/java/net/minecraftforge/common/brewing/BrewingOreRecipe.java +++ b/src/main/java/net/minecraftforge/common/brewing/BrewingOreRecipe.java @@ -19,7 +19,7 @@ public class BrewingOreRecipe extends AbstractBrewingRecipe> { @Override public boolean isIngredient(ItemStack stack) { - for (ItemStack target : this.ingredient) + for (ItemStack target : this.getIngredient()) { if (OreDictionary.itemMatches(target, stack, false)) { diff --git a/src/main/java/net/minecraftforge/common/brewing/BrewingRecipe.java b/src/main/java/net/minecraftforge/common/brewing/BrewingRecipe.java index e2b6ce906..1ce78812a 100644 --- a/src/main/java/net/minecraftforge/common/brewing/BrewingRecipe.java +++ b/src/main/java/net/minecraftforge/common/brewing/BrewingRecipe.java @@ -13,6 +13,6 @@ public class BrewingRecipe extends AbstractBrewingRecipe { @Override public boolean isIngredient(ItemStack stack) { - return OreDictionary.itemMatches(this.ingredient, stack, false); + return OreDictionary.itemMatches(this.getIngredient(), stack, false); } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/config/ConfigCategory.java b/src/main/java/net/minecraftforge/common/config/ConfigCategory.java index f90938a10..a98b194af 100644 --- a/src/main/java/net/minecraftforge/common/config/ConfigCategory.java +++ b/src/main/java/net/minecraftforge/common/config/ConfigCategory.java @@ -286,7 +286,7 @@ public class ConfigCategory implements Map { Property prop = props[x]; - if (prop.comment != null && !prop.comment.isEmpty()) + if (prop.getComment() != null && !prop.getComment().isEmpty()) { if (x != 0) { @@ -294,7 +294,7 @@ public class ConfigCategory implements Map } Splitter splitter = Splitter.onPattern("\r?\n"); - for (String commentLine : splitter.split(prop.comment)) + for (String commentLine : splitter.split(prop.getComment())) { write(out, pad1, "# ", commentLine); } diff --git a/src/main/java/net/minecraftforge/common/config/ConfigElement.java b/src/main/java/net/minecraftforge/common/config/ConfigElement.java index a6a196be5..d09689d05 100644 --- a/src/main/java/net/minecraftforge/common/config/ConfigElement.java +++ b/src/main/java/net/minecraftforge/common/config/ConfigElement.java @@ -148,7 +148,7 @@ public class ConfigElement implements IConfigElement @Override public String getComment() { - return isProperty ? prop.comment : category.getComment(); + return isProperty ? prop.getComment() : category.getComment(); } @Override diff --git a/src/main/java/net/minecraftforge/common/config/Configuration.java b/src/main/java/net/minecraftforge/common/config/Configuration.java index 573c21a89..13c34e06c 100644 --- a/src/main/java/net/minecraftforge/common/config/Configuration.java +++ b/src/main/java/net/minecraftforge/common/config/Configuration.java @@ -706,7 +706,7 @@ public class Configuration } prop.setDefaultValue(defaultValue); - prop.comment = comment; + prop.setComment(comment); return prop; } else if (defaultValue != null) @@ -715,7 +715,7 @@ public class Configuration prop.setValue(defaultValue); //Set and mark as dirty to signify it should save cat.put(key, prop); prop.setDefaultValue(defaultValue); - prop.comment = comment; + prop.setComment(comment); return prop; } else @@ -754,7 +754,7 @@ public class Configuration } prop.setDefaultValues(defaultValues); - prop.comment = comment; + prop.setComment(comment); return prop; } @@ -762,7 +762,7 @@ public class Configuration { Property prop = new Property(key, defaultValues, type); prop.setDefaultValues(defaultValues); - prop.comment = comment; + prop.setComment(comment); cat.put(key, prop); return prop; } @@ -1517,7 +1517,7 @@ public class Configuration Property prop = this.get(category, name, defaultValue); prop.setLanguageKey(langKey); prop.setValidationPattern(pattern); - prop.comment = comment + " [default: " + defaultValue + "]"; + prop.setComment(comment + " [default: " + defaultValue + "]"); return prop.getString(); } @@ -1552,7 +1552,7 @@ public class Configuration Property prop = this.get(category, name, defaultValue); prop.setValidValues(validValues); prop.setLanguageKey(langKey); - prop.comment = comment + " [default: " + defaultValue + "]"; + prop.setComment(comment + " [default: " + defaultValue + "]"); return prop.getString(); } @@ -1598,7 +1598,7 @@ public class Configuration Property prop = this.get(category, name, defaultValue); prop.setLanguageKey(langKey); prop.setValidValues(validValues); - prop.comment = comment + " [default: " + prop.getDefault() + "]"; + prop.setComment(comment + " [default: " + prop.getDefault() + "]"); return prop.getStringList(); } @@ -1630,7 +1630,7 @@ public class Configuration { Property prop = this.get(category, name, defaultValue); prop.setLanguageKey(langKey); - prop.comment = comment + " [default: " + defaultValue + "]"; + prop.setComment(comment + " [default: " + defaultValue + "]"); return prop.getBoolean(defaultValue); } @@ -1666,7 +1666,7 @@ public class Configuration { Property prop = this.get(category, name, defaultValue); prop.setLanguageKey(langKey); - prop.comment = comment + " [range: " + minValue + " ~ " + maxValue + ", default: " + defaultValue + "]"; + prop.setComment(comment + " [range: " + minValue + " ~ " + maxValue + ", default: " + defaultValue + "]"); prop.setMinValue(minValue); prop.setMaxValue(maxValue); return prop.getInt(defaultValue) < minValue ? minValue : (prop.getInt(defaultValue) > maxValue ? maxValue : prop.getInt(defaultValue)); @@ -1704,7 +1704,7 @@ public class Configuration { Property prop = this.get(category, name, Float.toString(defaultValue), name); prop.setLanguageKey(langKey); - prop.comment = comment + " [range: " + minValue + " ~ " + maxValue + ", default: " + defaultValue + "]"; + prop.setComment(comment + " [range: " + minValue + " ~ " + maxValue + ", default: " + defaultValue + "]"); prop.setMinValue(minValue); prop.setMaxValue(maxValue); try diff --git a/src/main/java/net/minecraftforge/common/config/Property.java b/src/main/java/net/minecraftforge/common/config/Property.java index 094ad0c49..db85afed2 100644 --- a/src/main/java/net/minecraftforge/common/config/Property.java +++ b/src/main/java/net/minecraftforge/common/config/Property.java @@ -14,6 +14,16 @@ import net.minecraftforge.fml.client.config.GuiEditArrayEntries.IArrayEntry; public class Property { + public String getComment() + { + return comment; + } + + public void setComment(String comment) + { + this.comment = comment; + } + public enum Type { STRING, @@ -45,7 +55,7 @@ public class Property private String name; private String value; private String defaultValue; - public String comment; + private String comment; private String[] values; private String[] defaultValues; private String[] validValues; @@ -113,7 +123,7 @@ public class Property this.minValue = String.valueOf(Integer.MIN_VALUE); this.maxValue = String.valueOf(Integer.MAX_VALUE); this.langKey = langKey; - this.comment = ""; + this.setComment(""); } public Property(String name, String[] values, Type type) @@ -155,7 +165,7 @@ public class Property this.minValue = String.valueOf(Integer.MIN_VALUE); this.maxValue = String.valueOf(Integer.MAX_VALUE); this.langKey = langKey; - this.comment = ""; + this.setComment(""); } /** diff --git a/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java b/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java index c1de2a376..1e29527a7 100644 --- a/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java +++ b/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java @@ -5,11 +5,11 @@ import java.io.Serializable; import net.minecraft.block.state.IBlockState; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.fml.common.registry.GameRegistry; -import net.minecraftforge.fml.common.registry.GameRegistry.UniqueIdentifier; /** * Represents a captured snapshot of a block which will not change @@ -23,57 +23,57 @@ public class BlockSnapshot implements Serializable { private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockSnapshot", "false")); - public final BlockPos pos; - public final int dimId; - public transient IBlockState replacedBlock; - public int flag; + private final BlockPos pos; + private final int dimId; + private transient IBlockState replacedBlock; + private int flag; private final NBTTagCompound nbt; - public transient World world; - public final UniqueIdentifier blockIdentifier; - public final int meta; + private transient World world; + private final ResourceLocation registryName; + private final int meta; public BlockSnapshot(World world, BlockPos pos, IBlockState state) { - this.world = world; + this.setWorld(world); this.dimId = world.provider.getDimension(); this.pos = pos; - this.replacedBlock = state; - this.blockIdentifier = GameRegistry.findUniqueIdentifierFor(state.getBlock()); + this.setReplacedBlock(state); + this.registryName = new ResourceLocation(state.getBlock().getRegistryName()); this.meta = state.getBlock().getMetaFromState(state); - this.flag = 3; + this.setFlag(3); TileEntity te = world.getTileEntity(pos); if (te != null) { nbt = new NBTTagCompound(); - te.writeToNBT(nbt); + te.writeToNBT(getNbt()); } else nbt = null; if (DEBUG) { - System.out.printf("Created BlockSnapshot - [World: %s ][Location: %d,%d,%d ][Block: %s ][Meta: %d ]", world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ(), blockIdentifier, meta); + System.out.printf("Created BlockSnapshot - [World: %s ][Location: %d,%d,%d ][Block: %s ][Meta: %d ]", world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ(), getRegistryName(), getMeta()); } } public BlockSnapshot(World world, BlockPos pos, IBlockState state, NBTTagCompound nbt) { - this.world = world; + this.setWorld(world); this.dimId = world.provider.getDimension(); this.pos = pos.getImmutable(); - this.replacedBlock = state; - this.blockIdentifier = GameRegistry.findUniqueIdentifierFor(state.getBlock()); + this.setReplacedBlock(state); + this.registryName = new ResourceLocation(state.getBlock().getRegistryName()); this.meta = state.getBlock().getMetaFromState(state); - this.flag = 3; + this.setFlag(3); this.nbt = nbt; if (DEBUG) { - System.out.printf("Created BlockSnapshot - [World: %s ][Location: %d,%d,%d ][Block: %s ][Meta: %d ]", world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ(), blockIdentifier, meta); + System.out.printf("Created BlockSnapshot - [World: %s ][Location: %d,%d,%d ][Block: %s ][Meta: %d ]", world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ(), getRegistryName(), getMeta()); } } public BlockSnapshot(World world, BlockPos pos, IBlockState state, int flag) { this(world, pos, state); - this.flag = flag; + this.setFlag(flag); } /** @@ -83,8 +83,8 @@ public class BlockSnapshot implements Serializable { this.dimId = dimension; this.pos = pos.getImmutable(); - this.flag = flag; - this.blockIdentifier = new UniqueIdentifier(modId + ":" + blockName); + this.setFlag(flag); + this.registryName = new ResourceLocation(modId, blockName); this.meta = meta; this.nbt = nbt; } @@ -115,14 +115,14 @@ public class BlockSnapshot implements Serializable public IBlockState getCurrentBlock() { - return world.getBlockState(pos); + return getWorld().getBlockState(getPos()); } public World getWorld() { if (this.world == null) { - this.world = DimensionManager.getWorld(dimId); + this.world = DimensionManager.getWorld(getDimId()); } return this.world; } @@ -131,15 +131,15 @@ public class BlockSnapshot implements Serializable { if (this.replacedBlock == null) { - this.replacedBlock = GameRegistry.findBlock(this.blockIdentifier.modId, this.blockIdentifier.name).getStateFromMeta(meta); + this.replacedBlock = GameRegistry.findBlock(this.getRegistryName().getResourceDomain(), this.getRegistryName().getResourcePath()).getStateFromMeta(getMeta()); } return this.replacedBlock; } public TileEntity getTileEntity() { - if (nbt != null) - return TileEntity.createTileEntity(getWorld().getMinecraftServer(), nbt); + if (getNbt() != null) + return TileEntity.createTileEntity(getWorld().getMinecraftServer(), getNbt()); else return null; } @@ -161,7 +161,7 @@ public class BlockSnapshot implements Serializable { if (force) { - world.setBlockState(pos, replaced, applyPhysics ? 3 : 2); + getWorld().setBlockState(getPos(), replaced, applyPhysics ? 3 : 2); } else { @@ -169,21 +169,21 @@ public class BlockSnapshot implements Serializable } } - world.setBlockState(pos, replaced, applyPhysics ? 3 : 2); - world.notifyBlockUpdate(pos, current, replaced, applyPhysics ? 3 : 2); + getWorld().setBlockState(getPos(), replaced, applyPhysics ? 3 : 2); + getWorld().notifyBlockUpdate(getPos(), current, replaced, applyPhysics ? 3 : 2); TileEntity te = null; - if (nbt != null) + if (getNbt() != null) { - te = world.getTileEntity(pos); + te = getWorld().getTileEntity(getPos()); if (te != null) { - te.readFromNBT(nbt); + te.readFromNBT(getNbt()); } } if (DEBUG) { - System.out.printf("Restored BlockSnapshot with data [World: %s ][Location: %d,%d,%d ][Meta: %d ][Block: %s ][TileEntity: %s ][force: %s ][applyPhysics: %s]", world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ(), replaced.getBlock().getMetaFromState(replaced), replaced.getBlock().delegate.name(), te, force, applyPhysics); + System.out.printf("Restored BlockSnapshot with data [World: %s ][Location: %d,%d,%d ][Meta: %d ][Block: %s ][TileEntity: %s ][force: %s ][applyPhysics: %s]", getWorld().getWorldInfo().getWorldName(), getPos().getX(), getPos().getY(), getPos().getZ(), replaced.getBlock().getMetaFromState(replaced), replaced.getBlock().delegate.name(), te, force, applyPhysics); } return true; } @@ -207,12 +207,12 @@ public class BlockSnapshot implements Serializable world.setBlockState(pos, replaced, applyPhysics ? 3 : 2); world.notifyBlockUpdate(pos, current, replaced, applyPhysics ? 3 : 2); TileEntity te = null; - if (nbt != null) + if (getNbt() != null) { te = world.getTileEntity(pos); if (te != null) { - te.readFromNBT(nbt); + te.readFromNBT(getNbt()); } } @@ -225,20 +225,20 @@ public class BlockSnapshot implements Serializable public void writeToNBT(NBTTagCompound compound) { - compound.setString("blockMod", blockIdentifier.modId); - compound.setString("blockName", blockIdentifier.name); - compound.setInteger("posX", pos.getX()); - compound.setInteger("posY", pos.getY()); - compound.setInteger("posZ", pos.getZ()); - compound.setInteger("flag", flag); - compound.setInteger("dimension", dimId); - compound.setInteger("metadata", meta); + compound.setString("blockMod", getRegistryName().getResourceDomain()); + compound.setString("blockName", getRegistryName().getResourcePath()); + compound.setInteger("posX", getPos().getX()); + compound.setInteger("posY", getPos().getY()); + compound.setInteger("posZ", getPos().getZ()); + compound.setInteger("flag", getFlag()); + compound.setInteger("dimension", getDimId()); + compound.setInteger("metadata", getMeta()); - compound.setBoolean("hasTE", nbt != null); + compound.setBoolean("hasTE", getNbt() != null); - if (nbt != null) + if (getNbt() != null) { - compound.setTag("tileEntity", nbt); + compound.setTag("tileEntity", getNbt()); } } @@ -254,27 +254,27 @@ public class BlockSnapshot implements Serializable return false; } final BlockSnapshot other = (BlockSnapshot) obj; - if (!this.pos.equals(other.pos)) + if (!this.getPos().equals(other.getPos())) { return false; } - if (this.meta != other.meta) + if (this.getMeta() != other.getMeta()) { return false; } - if (this.dimId != other.dimId) + if (this.getDimId() != other.getDimId()) { return false; } - if (this.nbt != other.nbt && (this.nbt == null || !this.nbt.equals(other.nbt))) + if (this.getNbt() != other.getNbt() && (this.getNbt() == null || !this.getNbt().equals(other.getNbt()))) { return false; } - if (this.world != other.world && (this.world == null || !this.world.equals(other.world))) + if (this.getWorld() != other.getWorld() && (this.getWorld() == null || !this.getWorld().equals(other.getWorld()))) { return false; } - if (this.blockIdentifier != other.blockIdentifier && (this.blockIdentifier == null || !this.blockIdentifier.equals(other.blockIdentifier))) + if (this.getRegistryName() != other.getRegistryName() && (this.getRegistryName() == null || !this.getRegistryName().equals(other.getRegistryName()))) { return false; } @@ -285,14 +285,24 @@ public class BlockSnapshot implements Serializable public int hashCode() { int hash = 7; - hash = 73 * hash + this.pos.getX(); - hash = 73 * hash + this.pos.getY(); - hash = 73 * hash + this.pos.getZ(); - hash = 73 * hash + this.meta; - hash = 73 * hash + this.dimId; - hash = 73 * hash + (this.nbt != null ? this.nbt.hashCode() : 0); - hash = 73 * hash + (this.world != null ? this.world.hashCode() : 0); - hash = 73 * hash + (this.blockIdentifier != null ? this.blockIdentifier.hashCode() : 0); + hash = 73 * hash + this.getPos().getX(); + hash = 73 * hash + this.getPos().getY(); + hash = 73 * hash + this.getPos().getZ(); + hash = 73 * hash + this.getMeta(); + hash = 73 * hash + this.getDimId(); + hash = 73 * hash + (this.getNbt() != null ? this.getNbt().hashCode() : 0); + hash = 73 * hash + (this.getWorld() != null ? this.getWorld().hashCode() : 0); + hash = 73 * hash + (this.getRegistryName() != null ? this.getRegistryName().hashCode() : 0); return hash; } + + public BlockPos getPos() { return pos; } + public int getDimId() { return dimId; } + public void setReplacedBlock(IBlockState replacedBlock) { this.replacedBlock = replacedBlock; } + public int getFlag() { return flag; } + public void setFlag(int flag) { this.flag = flag; } + public NBTTagCompound getNbt() { return nbt; } + public void setWorld(World world) { this.world = world; } + public ResourceLocation getRegistryName() { return registryName; } + public int getMeta() { return meta; } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java index 99f18e3fb..14ce1536e 100644 --- a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -94,7 +94,7 @@ public class ForgeEventFactory public static MultiPlaceEvent onPlayerMultiBlockPlace(EntityPlayer player, List blockSnapshots, EnumFacing direction) { BlockSnapshot snap = blockSnapshots.get(0); - IBlockState placedAgainst = snap.world.getBlockState(snap.pos.offset(direction.getOpposite())); + IBlockState placedAgainst = snap.getWorld().getBlockState(snap.getPos().offset(direction.getOpposite())); MultiPlaceEvent event = new MultiPlaceEvent(blockSnapshots, placedAgainst, player); MinecraftForge.EVENT_BUS.post(event); return event; @@ -102,7 +102,7 @@ public class ForgeEventFactory public static PlaceEvent onPlayerBlockPlace(EntityPlayer player, BlockSnapshot blockSnapshot, EnumFacing direction) { - IBlockState placedAgainst = blockSnapshot.world.getBlockState(blockSnapshot.pos.offset(direction.getOpposite())); + IBlockState placedAgainst = blockSnapshot.getWorld().getBlockState(blockSnapshot.getPos().offset(direction.getOpposite())); PlaceEvent event = new PlaceEvent(blockSnapshot, placedAgainst, player); MinecraftForge.EVENT_BUS.post(event); return event; diff --git a/src/main/java/net/minecraftforge/event/world/BlockEvent.java b/src/main/java/net/minecraftforge/event/world/BlockEvent.java index 47d620bd8..01b90398f 100644 --- a/src/main/java/net/minecraftforge/event/world/BlockEvent.java +++ b/src/main/java/net/minecraftforge/event/world/BlockEvent.java @@ -154,7 +154,7 @@ public class BlockEvent extends Event public PlaceEvent(BlockSnapshot blockSnapshot, IBlockState placedAgainst, EntityPlayer player) { - super(blockSnapshot.world, blockSnapshot.pos, blockSnapshot.getCurrentBlock()); + super(blockSnapshot.getWorld(), blockSnapshot.getPos(), blockSnapshot.getCurrentBlock()); this.player = player; this.itemInHand = player.getHeldItemMainhand(); this.blockSnapshot = blockSnapshot; diff --git a/src/main/java/net/minecraftforge/fluids/FluidEvent.java b/src/main/java/net/minecraftforge/fluids/FluidEvent.java index 7bb34f14e..73427962c 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidEvent.java +++ b/src/main/java/net/minecraftforge/fluids/FluidEvent.java @@ -8,9 +8,9 @@ import net.minecraftforge.fml.common.eventhandler.Event; public class FluidEvent extends Event { - public final FluidStack fluid; - public final World world; - public final BlockPos pos; + private final FluidStack fluid; + private final World world; + private final BlockPos pos; public FluidEvent(FluidStack fluid, World world, BlockPos pos) { @@ -19,6 +19,21 @@ public class FluidEvent extends Event this.pos = pos; } + public FluidStack getFluid() + { + return fluid; + } + + public World getWorld() + { + return world; + } + + public BlockPos getPos() + { + return pos; + } + /** * Mods should fire this event when they move fluids around. * @@ -38,8 +53,8 @@ public class FluidEvent extends Event */ public static class FluidFillingEvent extends FluidEvent { - public final IFluidTank tank; - public final int amount; + private final IFluidTank tank; + private final int amount; public FluidFillingEvent(FluidStack fluid, World world, BlockPos pos, IFluidTank tank, int amount) { @@ -47,6 +62,16 @@ public class FluidEvent extends Event this.tank = tank; this.amount = amount; } + + public IFluidTank getTank() + { + return tank; + } + + public int getAmount() + { + return amount; + } } /** @@ -56,8 +81,8 @@ public class FluidEvent extends Event */ public static class FluidDrainingEvent extends FluidEvent { - public final IFluidTank tank; - public final int amount; + private final IFluidTank tank; + private final int amount; public FluidDrainingEvent(FluidStack fluid, World world, BlockPos pos, IFluidTank tank, int amount) { @@ -65,6 +90,16 @@ public class FluidEvent extends Event this.amount = amount; this.tank = tank; } + + public IFluidTank getTank() + { + return tank; + } + + public int getAmount() + { + return amount; + } } /** diff --git a/src/main/java/net/minecraftforge/fluids/UniversalBucket.java b/src/main/java/net/minecraftforge/fluids/UniversalBucket.java index 0c612204c..751b99b36 100644 --- a/src/main/java/net/minecraftforge/fluids/UniversalBucket.java +++ b/src/main/java/net/minecraftforge/fluids/UniversalBucket.java @@ -36,9 +36,9 @@ import java.util.List; public class UniversalBucket extends Item implements IFluidContainerItem { - public final int capacity; // how much the bucket holds - public final ItemStack empty; // empty item to return and recognize when filling - public final boolean nbtSensitive; + private final int capacity; // how much the bucket holds + private final ItemStack empty; // empty item to return and recognize when filling + private final boolean nbtSensitive; public UniversalBucket() { @@ -68,7 +68,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) { // add all fluids that the bucket can be filled with - FluidStack fs = new FluidStack(fluid, capacity); + FluidStack fs = new FluidStack(fluid, getCapacity()); ItemStack stack = new ItemStack(this); if (fill(stack, fs, true) == fs.amount) { @@ -83,9 +83,9 @@ public class UniversalBucket extends Item implements IFluidContainerItem FluidStack fluidStack = getFluid(stack); if (fluidStack == null) { - if(empty != null) + if(getEmpty() != null) { - return empty.getDisplayName(); + return getEmpty().getDisplayName(); } return super.getItemStackDisplayName(stack); } @@ -132,7 +132,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem player.addStat(StatList.func_188057_b(this)); itemstack.stackSize--; - ItemStack emptyStack = empty != null ? empty.copy() : new ItemStack(this); + ItemStack emptyStack = getEmpty() != null ? getEmpty().copy() : new ItemStack(this); // check whether we replace the item or add the empty one to the inventory if (itemstack.stackSize <= 0) @@ -210,8 +210,8 @@ public class UniversalBucket extends Item implements IFluidContainerItem // not for us to handle if (event.getEmptyBucket() == null || - !event.getEmptyBucket().isItemEqual(empty) || - (nbtSensitive && ItemStack.areItemStackTagsEqual(event.getEmptyBucket(), empty))) + !event.getEmptyBucket().isItemEqual(getEmpty()) || + (isNbtSensitive() && ItemStack.areItemStackTagsEqual(event.getEmptyBucket(), getEmpty()))) { return; } @@ -233,7 +233,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem { FluidStack drained = fluidBlock.drain(world, pos, false); // check if it fits exactly - if (drained != null && drained.amount == capacity) + if (drained != null && drained.amount == getCapacity()) { // check if the container accepts it ItemStack filledBucket = new ItemStack(this); @@ -262,7 +262,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem public static ItemStack getFilledBucket(UniversalBucket item, Fluid fluid) { ItemStack stack = new ItemStack(item); - item.fill(stack, new FluidStack(fluid, item.capacity), true); + item.fill(stack, new FluidStack(fluid, item.getCapacity()), true); return stack; } @@ -277,7 +277,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem @Override public int getCapacity(ItemStack container) { - return capacity; + return getCapacity(); } @Override @@ -290,7 +290,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem } // can only fill exact capacity - if (resource == null || resource.amount != capacity) + if (resource == null || resource.amount != getCapacity()) { return 0; } @@ -310,14 +310,14 @@ public class UniversalBucket extends Item implements IFluidContainerItem resource.writeToNBT(tag); container.setTagCompound(tag); } - return capacity; + return getCapacity(); } @Override public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) { // can only drain everything at once - if (maxDrain < capacity) + if (maxDrain < getCapacity()) { return null; } @@ -325,11 +325,11 @@ public class UniversalBucket extends Item implements IFluidContainerItem FluidStack fluidStack = getFluid(container); if (doDrain && fluidStack != null) { - if(empty != null) + if(getEmpty() != null) { - container.setItem(empty.getItem()); - container.setTagCompound(empty.getTagCompound()); - container.setItemDamage(empty.getItemDamage()); + container.setItem(getEmpty().getItem()); + container.setTagCompound(getEmpty().getTagCompound()); + container.setItemDamage(getEmpty().getItemDamage()); } else { container.stackSize = 0; @@ -338,4 +338,19 @@ public class UniversalBucket extends Item implements IFluidContainerItem return fluidStack; } + + public int getCapacity() + { + return capacity; + } + + public ItemStack getEmpty() + { + return empty; + } + + public boolean isNbtSensitive() + { + return nbtSensitive; + } } diff --git a/src/main/java/net/minecraftforge/fml/client/event/ConfigChangedEvent.java b/src/main/java/net/minecraftforge/fml/client/event/ConfigChangedEvent.java index 1eaaf8910..f7c78344c 100644 --- a/src/main/java/net/minecraftforge/fml/client/event/ConfigChangedEvent.java +++ b/src/main/java/net/minecraftforge/fml/client/event/ConfigChangedEvent.java @@ -29,23 +29,11 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult; @HasResult public class ConfigChangedEvent extends Event { - /** - * The Mod ID of the mod whose configuration just changed. - */ - public final String modID; - /** - * Whether or not a world is currently running. - */ - public final boolean isWorldRunning; - /** - * Will be set to true if any elements were changed that require a restart of Minecraft. - */ - public final boolean requiresMcRestart; - /** - * A String identifier for this ConfigChangedEvent. - */ - public final String configID; - + private final String modID; + private final boolean isWorldRunning; + private final boolean requiresMcRestart; + private final String configID; + public ConfigChangedEvent(String modID, String configID, boolean isWorldRunning, boolean requiresMcRestart) { this.modID = modID; @@ -53,7 +41,39 @@ public class ConfigChangedEvent extends Event this.isWorldRunning = isWorldRunning; this.requiresMcRestart = requiresMcRestart; } - + + /** + * The Mod ID of the mod whose configuration just changed. + */ + public String getModID() + { + return modID; + } + + /** + * Whether or not a world is currently running. + */ + public boolean isWorldRunning() + { + return isWorldRunning; + } + + /** + * Will be set to true if any elements were changed that require a restart of Minecraft. + */ + public boolean isRequiresMcRestart() + { + return requiresMcRestart; + } + + /** + * A String identifier for this ConfigChangedEvent. + */ + public String getConfigID() + { + return configID; + } + /** * This event is intended to be consumed by the mod whose config has been changed. It fires when the Done button * has been clicked on a GuiConfig screen and the following conditions are met:
diff --git a/src/main/java/net/minecraftforge/fml/common/event/FMLFingerprintViolationEvent.java b/src/main/java/net/minecraftforge/fml/common/event/FMLFingerprintViolationEvent.java index 3f351563f..d8ffc2891 100644 --- a/src/main/java/net/minecraftforge/fml/common/event/FMLFingerprintViolationEvent.java +++ b/src/main/java/net/minecraftforge/fml/common/event/FMLFingerprintViolationEvent.java @@ -25,10 +25,10 @@ import net.minecraftforge.fml.common.Mod; */ public class FMLFingerprintViolationEvent extends FMLEvent { - public final boolean isDirectory; - public final Set fingerprints; - public final File source; - public final String expectedFingerprint; + private final boolean isDirectory; + private final Set fingerprints; + private final File source; + private final String expectedFingerprint; public FMLFingerprintViolationEvent(boolean isDirectory, File source, ImmutableSet fingerprints, String expectedFingerprint) { @@ -38,4 +38,9 @@ public class FMLFingerprintViolationEvent extends FMLEvent { this.fingerprints = fingerprints; this.expectedFingerprint = expectedFingerprint; } + + public boolean isDirectory() { return isDirectory; } + public Set getFingerprints() { return fingerprints; } + public File getSource() { return source; } + public String getExpectedFingerprint() { return expectedFingerprint; } } diff --git a/src/main/java/net/minecraftforge/fml/common/network/internal/FMLProxyPacket.java b/src/main/java/net/minecraftforge/fml/common/network/internal/FMLProxyPacket.java index 77dfa716d..ba3c4b336 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/internal/FMLProxyPacket.java +++ b/src/main/java/net/minecraftforge/fml/common/network/internal/FMLProxyPacket.java @@ -125,6 +125,7 @@ public class FMLProxyPacket implements Packet { } static final int PART_SIZE = 0x1000000 - 0x50; // Make it a constant so that it gets inlined below. + // FIXME int overflow public static final int MAX_LENGTH = PART_SIZE * 255; public List> toS3FPackets() throws IOException { diff --git a/src/main/java/net/minecraftforge/fml/common/registry/GameData.java b/src/main/java/net/minecraftforge/fml/common/registry/GameData.java index 3acf7ce18..b1e50740c 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/GameData.java +++ b/src/main/java/net/minecraftforge/fml/common/registry/GameData.java @@ -90,28 +90,6 @@ public class GameData return getMain().iBlockRegistry.getObject(new ResourceLocation(modId, name)); } - @Deprecated - static GameRegistry.UniqueIdentifier getUniqueName(Block block) - { - if (block == null) - { - return null; - } - Object name = getMain().iBlockRegistry.getNameForObject(block); - return new GameRegistry.UniqueIdentifier(name); - } - - @Deprecated - static GameRegistry.UniqueIdentifier getUniqueName(Item item) - { - if (item == null) - { - return null; - } - Object name = getMain().iItemRegistry.getNameForObject(item); - return new GameRegistry.UniqueIdentifier(name); - } - protected static GameData getMain() { return mainData; diff --git a/src/main/java/net/minecraftforge/fml/common/registry/GameRegistry.java b/src/main/java/net/minecraftforge/fml/common/registry/GameRegistry.java index dd9d7feea..ee11a01ec 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/GameRegistry.java +++ b/src/main/java/net/minecraftforge/fml/common/registry/GameRegistry.java @@ -388,112 +388,12 @@ public class GameRegistry return GameData.findItem(modId, name); } - /** - * Will be switching to using ResourceLocation, since it's used widely elsewhere - */ - @Deprecated - public static final class UniqueIdentifier - { - public final String modId; - public final String name; - - UniqueIdentifier(String modId, String name) - { - this.modId = modId; - this.name = name; - } - - public UniqueIdentifier(String string) - { - String[] parts = string.split(":"); - this.modId = parts[0]; - this.name = parts[1]; - } - - public UniqueIdentifier(Object obj) - { - if (obj instanceof String) - { - String[] parts = ((String)obj).split(":"); - this.modId = parts[0]; - this.name = parts[1]; - } - else if (obj instanceof ResourceLocation) - { - this.modId = ((ResourceLocation)obj).getResourceDomain(); - this.name = ((ResourceLocation)obj).getResourcePath(); - } - else - { - throw new IllegalArgumentException("UniqueIdentifier must be a String or ResourceLocation, was " + obj.getClass()); - } - } - - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - if (obj.getClass() != this.getClass()) - { - return false; - } - final UniqueIdentifier other = (UniqueIdentifier)obj; - return Objects.equal(modId, other.modId) && Objects.equal(name, other.name); - } - - @Override - public int hashCode() - { - return Objects.hashCode(modId, name); - } - - @Override - public String toString() - { - return String.format("%s:%s", modId, name); - } - } - public enum Type { BLOCK, ITEM; } - /** - * Look up the mod identifier data for a block. - *

- * Note: uniqueness and persistence is only guaranteed by mods using the game registry - * correctly. - * - * @param block to lookup - * @return a {@link UniqueIdentifier} for the block or null - */ - @Deprecated - public static UniqueIdentifier findUniqueIdentifierFor(Block block) - { - return GameData.getUniqueName(block); - } - - /** - * Look up the mod identifier data for an item. - *

- * Note: uniqueness and persistence is only guaranteed by mods using the game registry - * correctly. - * - * @param item to lookup - * @return a {@link UniqueIdentifier} for the item or null - */ - @Deprecated - public static UniqueIdentifier findUniqueIdentifierFor(Item item) - { - return GameData.getUniqueName(item); - } - - /** * ObjectHolder can be used to automatically populate public static final fields with entries * from the registry. These values can then be referred within mod code directly. diff --git a/src/main/java/net/minecraftforge/fml/relauncher/FMLInjectionData.java b/src/main/java/net/minecraftforge/fml/relauncher/FMLInjectionData.java index 6a9cf9b72..10a2116df 100644 --- a/src/main/java/net/minecraftforge/fml/relauncher/FMLInjectionData.java +++ b/src/main/java/net/minecraftforge/fml/relauncher/FMLInjectionData.java @@ -29,7 +29,7 @@ public class FMLInjectionData static String mccversion; static String mcpversion; - public static List containers = new ArrayList(); + public static final List containers = new ArrayList(); static void build(File mcHome, LaunchClassLoader classLoader) { diff --git a/src/main/java/net/minecraftforge/fml/relauncher/FMLRelaunchLog.java b/src/main/java/net/minecraftforge/fml/relauncher/FMLRelaunchLog.java index b2d8604a5..9acd7e01d 100644 --- a/src/main/java/net/minecraftforge/fml/relauncher/FMLRelaunchLog.java +++ b/src/main/java/net/minecraftforge/fml/relauncher/FMLRelaunchLog.java @@ -28,7 +28,7 @@ public class FMLRelaunchLog { * Our special logger for logging issues to. We copy various assets from the * Minecraft logger to achieve a similar appearance. */ - public static FMLRelaunchLog log = new FMLRelaunchLog(); + public static final FMLRelaunchLog log = new FMLRelaunchLog(); static File minecraftHome; private static boolean configured; diff --git a/src/main/java/net/minecraftforge/items/SlotItemHandler.java b/src/main/java/net/minecraftforge/items/SlotItemHandler.java index aa04c33be..e5571ebed 100644 --- a/src/main/java/net/minecraftforge/items/SlotItemHandler.java +++ b/src/main/java/net/minecraftforge/items/SlotItemHandler.java @@ -9,7 +9,7 @@ import net.minecraft.item.ItemStack; public class SlotItemHandler extends Slot { private static IInventory emptyInventory = new InventoryBasic("[Null]", true, 0); - public final IItemHandler itemHandler; + private final IItemHandler itemHandler; private final int index; public SlotItemHandler(IItemHandler itemHandler, int index, int xPosition, int yPosition) @@ -24,21 +24,21 @@ public class SlotItemHandler extends Slot { if (stack == null) return false; - ItemStack remainder = this.itemHandler.insertItem(index, stack, true); + ItemStack remainder = this.getItemHandler().insertItem(index, stack, true); return remainder == null || remainder.stackSize < stack.stackSize; } @Override public ItemStack getStack() { - return this.itemHandler.getStackInSlot(index); + return this.getItemHandler().getStackInSlot(index); } // Override if your IItemHandler does not implement IItemHandlerModifiable @Override public void putStack(ItemStack stack) { - ((IItemHandlerModifiable) this.itemHandler).setStackInSlot(index, stack); + ((IItemHandlerModifiable) this.getItemHandler()).setStackInSlot(index, stack); this.onSlotChanged(); } @@ -53,8 +53,8 @@ public class SlotItemHandler extends Slot { ItemStack maxAdd = stack.copy(); maxAdd.stackSize = maxAdd.getMaxStackSize(); - ItemStack currentStack = this.itemHandler.getStackInSlot(index); - ItemStack remainder = this.itemHandler.insertItem(index, maxAdd, true); + ItemStack currentStack = this.getItemHandler().getStackInSlot(index); + ItemStack remainder = this.getItemHandler().insertItem(index, maxAdd, true); int current = currentStack == null ? 0 : currentStack.stackSize; int added = maxAdd.stackSize - (remainder != null ? remainder.stackSize : 0); @@ -64,12 +64,17 @@ public class SlotItemHandler extends Slot @Override public boolean canTakeStack(EntityPlayer playerIn) { - return this.itemHandler.extractItem(index, 1, true) != null; + return this.getItemHandler().extractItem(index, 1, true) != null; } @Override public ItemStack decrStackSize(int amount) { - return this.itemHandler.extractItem(index, amount, false); + return this.getItemHandler().extractItem(index, amount, false); + } + + public IItemHandler getItemHandler() + { + return itemHandler; } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/items/wrapper/EmptyHandler.java b/src/main/java/net/minecraftforge/items/wrapper/EmptyHandler.java index e99314c97..15288927f 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/EmptyHandler.java +++ b/src/main/java/net/minecraftforge/items/wrapper/EmptyHandler.java @@ -6,7 +6,7 @@ import net.minecraftforge.items.IItemHandlerModifiable; public class EmptyHandler implements IItemHandlerModifiable { - public static IItemHandler INSTANCE = new EmptyHandler(); + public static final IItemHandler INSTANCE = new EmptyHandler(); @Override public int getSlots() diff --git a/src/main/java/net/minecraftforge/items/wrapper/InvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/InvWrapper.java index 6b722dc30..b86e934a5 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/InvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/InvWrapper.java @@ -7,7 +7,7 @@ import net.minecraftforge.items.ItemHandlerHelper; public class InvWrapper implements IItemHandlerModifiable { - public final IInventory inv; + private final IInventory inv; public InvWrapper(IInventory inv) { @@ -24,26 +24,26 @@ public class InvWrapper implements IItemHandlerModifiable InvWrapper that = (InvWrapper) o; - return inv.equals(that.inv); + return getInv().equals(that.getInv()); } @Override public int hashCode() { - return inv.hashCode(); + return getInv().hashCode(); } @Override public int getSlots() { - return inv.getSizeInventory(); + return getInv().getSizeInventory(); } @Override public ItemStack getStackInSlot(int slot) { - return inv.getStackInSlot(slot); + return getInv().getStackInSlot(slot); } @Override @@ -52,10 +52,10 @@ public class InvWrapper implements IItemHandlerModifiable if (stack == null) return null; - if (!inv.isItemValidForSlot(slot, stack)) + if (!getInv().isItemValidForSlot(slot, stack)) return stack; - ItemStack stackInSlot = inv.getStackInSlot(slot); + ItemStack stackInSlot = getInv().getStackInSlot(slot); int m; if (stackInSlot != null) @@ -63,7 +63,7 @@ public class InvWrapper implements IItemHandlerModifiable if (!ItemHandlerHelper.canItemStacksStack(stack, stackInSlot)) return stack; - m = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit()) - stackInSlot.stackSize; + m = Math.min(stack.getMaxStackSize(), getInv().getInventoryStackLimit()) - stackInSlot.stackSize; if (stack.stackSize <= m) { @@ -71,8 +71,8 @@ public class InvWrapper implements IItemHandlerModifiable { ItemStack copy = stack.copy(); copy.stackSize += stackInSlot.stackSize; - inv.setInventorySlotContents(slot, copy); - inv.markDirty(); + getInv().setInventorySlotContents(slot, copy); + getInv().markDirty(); } return null; @@ -85,8 +85,8 @@ public class InvWrapper implements IItemHandlerModifiable { ItemStack copy = stack.splitStack(m); copy.stackSize += stackInSlot.stackSize; - inv.setInventorySlotContents(slot, copy); - inv.markDirty(); + getInv().setInventorySlotContents(slot, copy); + getInv().markDirty(); return stack; } else @@ -98,15 +98,15 @@ public class InvWrapper implements IItemHandlerModifiable } else { - m = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit()); + m = Math.min(stack.getMaxStackSize(), getInv().getInventoryStackLimit()); if (m < stack.stackSize) { // copy the stack to not modify the original one stack = stack.copy(); if (!simulate) { - inv.setInventorySlotContents(slot, stack.splitStack(m)); - inv.markDirty(); + getInv().setInventorySlotContents(slot, stack.splitStack(m)); + getInv().markDirty(); return stack; } else @@ -119,8 +119,8 @@ public class InvWrapper implements IItemHandlerModifiable { if (!simulate) { - inv.setInventorySlotContents(slot, stack); - inv.markDirty(); + getInv().setInventorySlotContents(slot, stack); + getInv().markDirty(); } return null; } @@ -134,7 +134,7 @@ public class InvWrapper implements IItemHandlerModifiable if (amount == 0) return null; - ItemStack stackInSlot = inv.getStackInSlot(slot); + ItemStack stackInSlot = getInv().getStackInSlot(slot); if (stackInSlot == null) return null; @@ -156,8 +156,8 @@ public class InvWrapper implements IItemHandlerModifiable { int m = Math.min(stackInSlot.stackSize, amount); - ItemStack decrStackSize = inv.decrStackSize(slot, m); - inv.markDirty(); + ItemStack decrStackSize = getInv().decrStackSize(slot, m); + getInv().markDirty(); return decrStackSize; } } @@ -165,6 +165,11 @@ public class InvWrapper implements IItemHandlerModifiable @Override public void setStackInSlot(int slot, ItemStack stack) { - inv.setInventorySlotContents(slot, stack); + getInv().setInventorySlotContents(slot, stack); + } + + public IInventory getInv() + { + return inv; } } diff --git a/src/main/java/net/minecraftforge/items/wrapper/PlayerArmorInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/PlayerArmorInvWrapper.java index 063bec7e1..b63a82b87 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/PlayerArmorInvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/PlayerArmorInvWrapper.java @@ -6,7 +6,7 @@ import net.minecraft.item.ItemStack; public class PlayerArmorInvWrapper extends RangedWrapper { - public final InventoryPlayer inventoryPlayer; + private final InventoryPlayer inventoryPlayer; public PlayerArmorInvWrapper(InventoryPlayer inv) { @@ -27,10 +27,15 @@ public class PlayerArmorInvWrapper extends RangedWrapper } } // check if it's valid for the armor slot - if (slot < 4 && stack != null && stack.getItem().isValidArmor(stack, equ, inventoryPlayer.player)) + if (slot < 4 && stack != null && stack.getItem().isValidArmor(stack, equ, getInventoryPlayer().player)) { return super.insertItem(slot, stack, simulate); } return stack; } + + public InventoryPlayer getInventoryPlayer() + { + return inventoryPlayer; + } } diff --git a/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java index 421f65412..ec2a04f82 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/PlayerMainInvWrapper.java @@ -10,7 +10,7 @@ import net.minecraft.item.ItemStack; */ public class PlayerMainInvWrapper extends RangedWrapper { - public final InventoryPlayer inventoryPlayer; + private final InventoryPlayer inventoryPlayer; public PlayerMainInvWrapper(InventoryPlayer inv) { @@ -28,15 +28,20 @@ public class PlayerMainInvWrapper extends RangedWrapper ItemStack inSlot = getStackInSlot(slot); if(inSlot != null) { - if (inventoryPlayer.player.worldObj.isRemote) + if (getInventoryPlayer().player.worldObj.isRemote) { inSlot.animationsToGo = 5; } - else if(inventoryPlayer.player instanceof EntityPlayerMP) { - inventoryPlayer.player.openContainer.detectAndSendChanges(); + else if(getInventoryPlayer().player instanceof EntityPlayerMP) { + getInventoryPlayer().player.openContainer.detectAndSendChanges(); } } } return rest; } + + public InventoryPlayer getInventoryPlayer() + { + return inventoryPlayer; + } } diff --git a/src/main/java/net/minecraftforge/oredict/RecipeSorter.java b/src/main/java/net/minecraftforge/oredict/RecipeSorter.java index 8902c84a6..056fba7bb 100644 --- a/src/main/java/net/minecraftforge/oredict/RecipeSorter.java +++ b/src/main/java/net/minecraftforge/oredict/RecipeSorter.java @@ -108,7 +108,7 @@ public class RecipeSorter implements Comparator private static Map entries = Maps.newHashMap(); private static Map, Integer> priorities = Maps.newHashMap(); - public static RecipeSorter INSTANCE = new RecipeSorter(); + public static final RecipeSorter INSTANCE = new RecipeSorter(); private static boolean isDirty = true; private static SortEntry before = new SortEntry("Before", null, UNKNOWN, "");