Made some more public fields either private or final.

This commit is contained in:
RainWarrior 2016-03-24 13:14:39 +03:00
parent 756c58d5cb
commit 75032ebf9c
32 changed files with 355 additions and 331 deletions

View file

@ -19,9 +19,9 @@ public class SoundEvent extends Event
public static class SoundSourceEvent extends SoundEvent public static class SoundSourceEvent extends SoundEvent
{ {
public final ISound sound; private final ISound sound;
public final String uuid; private final String uuid;
public final String name; private final String name;
public SoundSourceEvent(SoundManager manager, ISound sound, String uuid) public SoundSourceEvent(SoundManager manager, ISound sound, String uuid)
{ {
@ -30,5 +30,20 @@ public class SoundEvent extends Event
this.sound = sound; this.sound = sound;
this.uuid = uuid; this.uuid = uuid;
} }
public ISound getSound()
{
return sound;
}
public String getUuid()
{
return uuid;
}
public String getName()
{
return name;
}
} }
} }

View file

@ -749,7 +749,7 @@ public class ForgeBlockStateV1 extends Marker
public static class TRSRDeserializer implements JsonDeserializer<TRSRTransformation> public static class TRSRDeserializer implements JsonDeserializer<TRSRTransformation>
{ {
public static TRSRDeserializer INSTANCE = new TRSRDeserializer(); public static final TRSRDeserializer INSTANCE = new TRSRDeserializer();
public TRSRTransformation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException public TRSRTransformation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{ {

View file

@ -841,8 +841,8 @@ public final class ModelLoader extends ModelBakery
*/ */
public static final class White extends TextureAtlasSprite public static final class White extends TextureAtlasSprite
{ {
public static ResourceLocation LOCATION = new ResourceLocation("white"); public static final ResourceLocation LOCATION = new ResourceLocation("white");
public static White INSTANCE = new White(); public static final White INSTANCE = new White();
private White() private White()
{ {

View file

@ -511,7 +511,7 @@ public class B3DModel
public static class Texture 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 String path;
private final int flags; private final int flags;
private final int blend; private final int blend;

View file

@ -1003,37 +1003,37 @@ public class ForgeChunkManager
.setCategoryRequiresWorldRestart("defaults", true); .setCategoryRequiresWorldRestart("defaults", true);
Property temp = config.get("defaults", "enabled", 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"); temp.setLanguageKey("forge.configgui.enableModOverrides");
overridesEnabled = temp.getBoolean(true); overridesEnabled = temp.getBoolean(true);
propOrder.add("enabled"); propOrder.add("enabled");
temp = config.get("defaults", "maximumChunksPerTicket", 25); temp = config.get("defaults", "maximumChunksPerTicket", 25);
temp.comment = "The default maximum number of chunks a mod can force, per ticket, \n" + 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."; "for a mod without an override. This is the maximum number of chunks a single ticket can force.");
temp.setLanguageKey("forge.configgui.maximumChunksPerTicket"); temp.setLanguageKey("forge.configgui.maximumChunksPerTicket");
temp.setMinValue(0); temp.setMinValue(0);
defaultMaxChunks = temp.getInt(25); defaultMaxChunks = temp.getInt(25);
propOrder.add("maximumChunksPerTicket"); propOrder.add("maximumChunksPerTicket");
temp = config.get("defaults", "maximumTicketCount", 200); temp = config.get("defaults", "maximumTicketCount", 200);
temp.comment = "The default maximum ticket count for a mod which does not have an override\n" + 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."; "in this file. This is the number of chunk loading requests a mod is allowed to make.");
temp.setLanguageKey("forge.configgui.maximumTicketCount"); temp.setLanguageKey("forge.configgui.maximumTicketCount");
temp.setMinValue(0); temp.setMinValue(0);
defaultMaxCount = temp.getInt(200); defaultMaxCount = temp.getInt(200);
propOrder.add("maximumTicketCount"); propOrder.add("maximumTicketCount");
temp = config.get("defaults", "playerTicketCount", 500); 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.setLanguageKey("forge.configgui.playerTicketCount");
temp.setMinValue(0); temp.setMinValue(0);
playerTicketLength = temp.getInt(500); playerTicketLength = temp.getInt(500);
propOrder.add("playerTicketCount"); propOrder.add("playerTicketCount");
temp = config.get("defaults", "dormantChunkCacheSize", 0); temp = config.get("defaults", "dormantChunkCacheSize", 0);
temp.comment = "Unloaded chunks can first be kept in a dormant cache for quicker\n" + 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"; "loading times. Specify the size (in chunks) of that cache here");
temp.setLanguageKey("forge.configgui.dormantChunkCacheSize"); temp.setLanguageKey("forge.configgui.dormantChunkCacheSize");
temp.setMinValue(0); temp.setMinValue(0);
dormantChunkCacheSize = temp.getInt(0); dormantChunkCacheSize = temp.getInt(0);
@ -1048,9 +1048,9 @@ public class ForgeChunkManager
"for that mod"); "for that mod");
temp = config.get("Forge", "maximumTicketCount", 200); 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 = 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()) for (String mod : config.getCategoryNames())
{ {
if (mod.equals("Forge") || mod.equals("defaults")) if (mod.equals("Forge") || mod.equals("defaults"))

View file

@ -777,15 +777,15 @@ public class ForgeHooks
for (BlockSnapshot snap : blockSnapshots) for (BlockSnapshot snap : blockSnapshots)
{ {
int updateFlag = snap.flag; int updateFlag = snap.getFlag();
IBlockState oldBlock = snap.replacedBlock; IBlockState oldBlock = snap.getReplacedBlock();
IBlockState newBlock = world.getBlockState(snap.pos); IBlockState newBlock = world.getBlockState(snap.getPos());
if (newBlock != null && !(newBlock.getBlock().hasTileEntity(newBlock))) // Containers get placed automatically 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())); player.addStat(StatList.func_188060_a(itemstack.getItem()));
} }

View file

@ -149,7 +149,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
Property prop; Property prop;
prop = config.get(CATEGORY_GENERAL, "disableVersionCheck", false); 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 // 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. // "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". // 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()); propOrder.add(prop.getName());
prop = config.get(CATEGORY_GENERAL, "sortRecipies", true); 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); prop.setLanguageKey("forge.configgui.sortRecipies").setRequiresMcRestart(true);
shouldSortRecipies = prop.getBoolean(shouldSortRecipies); shouldSortRecipies = prop.getBoolean(shouldSortRecipies);
propOrder.add(prop.getName()); propOrder.add(prop.getName());
prop = config.get(Configuration.CATEGORY_GENERAL, "removeErroringEntities", false); 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); prop.setLanguageKey("forge.configgui.removeErroringEntities").setRequiresWorldRestart(true);
removeErroringEntities = prop.getBoolean(false); removeErroringEntities = prop.getBoolean(false);
propOrder.add(prop.getName()); propOrder.add(prop.getName());
@ -187,7 +187,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
} }
prop = config.get(Configuration.CATEGORY_GENERAL, "removeErroringTileEntities", false); 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); prop.setLanguageKey("forge.configgui.removeErroringTileEntities").setRequiresWorldRestart(true);
removeErroringTileEntities = prop.getBoolean(false); removeErroringTileEntities = prop.getBoolean(false);
propOrder.add(prop.getName()); propOrder.add(prop.getName());
@ -198,17 +198,17 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
} }
prop = config.get(Configuration.CATEGORY_GENERAL, "disableStitchedFileSaving", true); 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); disableStitchedFileSaving = prop.getBoolean(true);
prop = config.get(Configuration.CATEGORY_GENERAL, "fullBoundingBoxLadders", false); 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); prop.setLanguageKey("forge.configgui.fullBoundingBoxLadders").setRequiresWorldRestart(true);
fullBoundingBoxLadders = prop.getBoolean(false); fullBoundingBoxLadders = prop.getBoolean(false);
propOrder.add(prop.getName()); 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 = 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"); prop.setLanguageKey("forge.configgui.biomeSkyBlendRange");
blendRanges = prop.getIntList(); blendRanges = prop.getIntList();
propOrder.add(prop.getName()); propOrder.add(prop.getName());
@ -274,18 +274,18 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
@SubscribeEvent @SubscribeEvent
public void onConfigChanged(OnConfigChangedEvent event) 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); syncConfig(false);
} }
else if ("chunkLoader".equals(event.configID)) else if ("chunkLoader".equals(event.getConfigID()))
{ {
ForgeChunkManager.syncConfigDefaults(); ForgeChunkManager.syncConfigDefaults();
ForgeChunkManager.loadConfiguration(); ForgeChunkManager.loadConfiguration();
} }
else if (VERSION_CHECK_CAT.equals(event.configID)) else if (VERSION_CHECK_CAT.equals(event.getConfigID()))
{ {
syncConfig(false); syncConfig(false);
} }

View file

@ -5,9 +5,9 @@ import net.minecraftforge.oredict.OreDictionary;
public abstract class AbstractBrewingRecipe<T> implements IBrewingRecipe { public abstract class AbstractBrewingRecipe<T> implements IBrewingRecipe {
public final ItemStack input; private final ItemStack input;
public final T ingredient; private final T ingredient;
public final ItemStack output; private final ItemStack output;
protected AbstractBrewingRecipe(ItemStack input, T ingredient, ItemStack output) protected AbstractBrewingRecipe(ItemStack input, T ingredient, ItemStack output)
{ {
@ -15,12 +15,12 @@ public abstract class AbstractBrewingRecipe<T> implements IBrewingRecipe {
this.ingredient = ingredient; this.ingredient = ingredient;
this.output = output; 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."); 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."); 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<T> implements IBrewingRecipe {
@Override @Override
public boolean isInput(ItemStack stack) public boolean isInput(ItemStack stack)
{ {
return OreDictionary.itemMatches(this.input, stack, false); return OreDictionary.itemMatches(this.getInput(), stack, false);
} }
@Override @Override
public ItemStack getOutput(ItemStack input, ItemStack ingredient) 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;
} }
} }

View file

@ -19,7 +19,7 @@ public class BrewingOreRecipe extends AbstractBrewingRecipe<List<ItemStack>> {
@Override @Override
public boolean isIngredient(ItemStack stack) public boolean isIngredient(ItemStack stack)
{ {
for (ItemStack target : this.ingredient) for (ItemStack target : this.getIngredient())
{ {
if (OreDictionary.itemMatches(target, stack, false)) if (OreDictionary.itemMatches(target, stack, false))
{ {

View file

@ -13,6 +13,6 @@ public class BrewingRecipe extends AbstractBrewingRecipe<ItemStack> {
@Override @Override
public boolean isIngredient(ItemStack stack) public boolean isIngredient(ItemStack stack)
{ {
return OreDictionary.itemMatches(this.ingredient, stack, false); return OreDictionary.itemMatches(this.getIngredient(), stack, false);
} }
} }

View file

@ -286,7 +286,7 @@ public class ConfigCategory implements Map<String, Property>
{ {
Property prop = props[x]; Property prop = props[x];
if (prop.comment != null && !prop.comment.isEmpty()) if (prop.getComment() != null && !prop.getComment().isEmpty())
{ {
if (x != 0) if (x != 0)
{ {
@ -294,7 +294,7 @@ public class ConfigCategory implements Map<String, Property>
} }
Splitter splitter = Splitter.onPattern("\r?\n"); Splitter splitter = Splitter.onPattern("\r?\n");
for (String commentLine : splitter.split(prop.comment)) for (String commentLine : splitter.split(prop.getComment()))
{ {
write(out, pad1, "# ", commentLine); write(out, pad1, "# ", commentLine);
} }

View file

@ -148,7 +148,7 @@ public class ConfigElement implements IConfigElement
@Override @Override
public String getComment() public String getComment()
{ {
return isProperty ? prop.comment : category.getComment(); return isProperty ? prop.getComment() : category.getComment();
} }
@Override @Override

View file

@ -706,7 +706,7 @@ public class Configuration
} }
prop.setDefaultValue(defaultValue); prop.setDefaultValue(defaultValue);
prop.comment = comment; prop.setComment(comment);
return prop; return prop;
} }
else if (defaultValue != null) else if (defaultValue != null)
@ -715,7 +715,7 @@ public class Configuration
prop.setValue(defaultValue); //Set and mark as dirty to signify it should save prop.setValue(defaultValue); //Set and mark as dirty to signify it should save
cat.put(key, prop); cat.put(key, prop);
prop.setDefaultValue(defaultValue); prop.setDefaultValue(defaultValue);
prop.comment = comment; prop.setComment(comment);
return prop; return prop;
} }
else else
@ -754,7 +754,7 @@ public class Configuration
} }
prop.setDefaultValues(defaultValues); prop.setDefaultValues(defaultValues);
prop.comment = comment; prop.setComment(comment);
return prop; return prop;
} }
@ -762,7 +762,7 @@ public class Configuration
{ {
Property prop = new Property(key, defaultValues, type); Property prop = new Property(key, defaultValues, type);
prop.setDefaultValues(defaultValues); prop.setDefaultValues(defaultValues);
prop.comment = comment; prop.setComment(comment);
cat.put(key, prop); cat.put(key, prop);
return prop; return prop;
} }
@ -1517,7 +1517,7 @@ public class Configuration
Property prop = this.get(category, name, defaultValue); Property prop = this.get(category, name, defaultValue);
prop.setLanguageKey(langKey); prop.setLanguageKey(langKey);
prop.setValidationPattern(pattern); prop.setValidationPattern(pattern);
prop.comment = comment + " [default: " + defaultValue + "]"; prop.setComment(comment + " [default: " + defaultValue + "]");
return prop.getString(); return prop.getString();
} }
@ -1552,7 +1552,7 @@ public class Configuration
Property prop = this.get(category, name, defaultValue); Property prop = this.get(category, name, defaultValue);
prop.setValidValues(validValues); prop.setValidValues(validValues);
prop.setLanguageKey(langKey); prop.setLanguageKey(langKey);
prop.comment = comment + " [default: " + defaultValue + "]"; prop.setComment(comment + " [default: " + defaultValue + "]");
return prop.getString(); return prop.getString();
} }
@ -1598,7 +1598,7 @@ public class Configuration
Property prop = this.get(category, name, defaultValue); Property prop = this.get(category, name, defaultValue);
prop.setLanguageKey(langKey); prop.setLanguageKey(langKey);
prop.setValidValues(validValues); prop.setValidValues(validValues);
prop.comment = comment + " [default: " + prop.getDefault() + "]"; prop.setComment(comment + " [default: " + prop.getDefault() + "]");
return prop.getStringList(); return prop.getStringList();
} }
@ -1630,7 +1630,7 @@ public class Configuration
{ {
Property prop = this.get(category, name, defaultValue); Property prop = this.get(category, name, defaultValue);
prop.setLanguageKey(langKey); prop.setLanguageKey(langKey);
prop.comment = comment + " [default: " + defaultValue + "]"; prop.setComment(comment + " [default: " + defaultValue + "]");
return prop.getBoolean(defaultValue); return prop.getBoolean(defaultValue);
} }
@ -1666,7 +1666,7 @@ public class Configuration
{ {
Property prop = this.get(category, name, defaultValue); Property prop = this.get(category, name, defaultValue);
prop.setLanguageKey(langKey); prop.setLanguageKey(langKey);
prop.comment = comment + " [range: " + minValue + " ~ " + maxValue + ", default: " + defaultValue + "]"; prop.setComment(comment + " [range: " + minValue + " ~ " + maxValue + ", default: " + defaultValue + "]");
prop.setMinValue(minValue); prop.setMinValue(minValue);
prop.setMaxValue(maxValue); prop.setMaxValue(maxValue);
return prop.getInt(defaultValue) < minValue ? minValue : (prop.getInt(defaultValue) > maxValue ? maxValue : prop.getInt(defaultValue)); 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); Property prop = this.get(category, name, Float.toString(defaultValue), name);
prop.setLanguageKey(langKey); prop.setLanguageKey(langKey);
prop.comment = comment + " [range: " + minValue + " ~ " + maxValue + ", default: " + defaultValue + "]"; prop.setComment(comment + " [range: " + minValue + " ~ " + maxValue + ", default: " + defaultValue + "]");
prop.setMinValue(minValue); prop.setMinValue(minValue);
prop.setMaxValue(maxValue); prop.setMaxValue(maxValue);
try try

View file

@ -14,6 +14,16 @@ import net.minecraftforge.fml.client.config.GuiEditArrayEntries.IArrayEntry;
public class Property public class Property
{ {
public String getComment()
{
return comment;
}
public void setComment(String comment)
{
this.comment = comment;
}
public enum Type public enum Type
{ {
STRING, STRING,
@ -45,7 +55,7 @@ public class Property
private String name; private String name;
private String value; private String value;
private String defaultValue; private String defaultValue;
public String comment; private String comment;
private String[] values; private String[] values;
private String[] defaultValues; private String[] defaultValues;
private String[] validValues; private String[] validValues;
@ -113,7 +123,7 @@ public class Property
this.minValue = String.valueOf(Integer.MIN_VALUE); this.minValue = String.valueOf(Integer.MIN_VALUE);
this.maxValue = String.valueOf(Integer.MAX_VALUE); this.maxValue = String.valueOf(Integer.MAX_VALUE);
this.langKey = langKey; this.langKey = langKey;
this.comment = ""; this.setComment("");
} }
public Property(String name, String[] values, Type type) public Property(String name, String[] values, Type type)
@ -155,7 +165,7 @@ public class Property
this.minValue = String.valueOf(Integer.MIN_VALUE); this.minValue = String.valueOf(Integer.MIN_VALUE);
this.maxValue = String.valueOf(Integer.MAX_VALUE); this.maxValue = String.valueOf(Integer.MAX_VALUE);
this.langKey = langKey; this.langKey = langKey;
this.comment = ""; this.setComment("");
} }
/** /**

View file

@ -5,11 +5,11 @@ import java.io.Serializable;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.fml.common.registry.GameRegistry; 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 * 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")); private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockSnapshot", "false"));
public final BlockPos pos; private final BlockPos pos;
public final int dimId; private final int dimId;
public transient IBlockState replacedBlock; private transient IBlockState replacedBlock;
public int flag; private int flag;
private final NBTTagCompound nbt; private final NBTTagCompound nbt;
public transient World world; private transient World world;
public final UniqueIdentifier blockIdentifier; private final ResourceLocation registryName;
public final int meta; private final int meta;
public BlockSnapshot(World world, BlockPos pos, IBlockState state) public BlockSnapshot(World world, BlockPos pos, IBlockState state)
{ {
this.world = world; this.setWorld(world);
this.dimId = world.provider.getDimension(); this.dimId = world.provider.getDimension();
this.pos = pos; this.pos = pos;
this.replacedBlock = state; this.setReplacedBlock(state);
this.blockIdentifier = GameRegistry.findUniqueIdentifierFor(state.getBlock()); this.registryName = new ResourceLocation(state.getBlock().getRegistryName());
this.meta = state.getBlock().getMetaFromState(state); this.meta = state.getBlock().getMetaFromState(state);
this.flag = 3; this.setFlag(3);
TileEntity te = world.getTileEntity(pos); TileEntity te = world.getTileEntity(pos);
if (te != null) if (te != null)
{ {
nbt = new NBTTagCompound(); nbt = new NBTTagCompound();
te.writeToNBT(nbt); te.writeToNBT(getNbt());
} }
else nbt = null; else nbt = null;
if (DEBUG) 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) public BlockSnapshot(World world, BlockPos pos, IBlockState state, NBTTagCompound nbt)
{ {
this.world = world; this.setWorld(world);
this.dimId = world.provider.getDimension(); this.dimId = world.provider.getDimension();
this.pos = pos.getImmutable(); this.pos = pos.getImmutable();
this.replacedBlock = state; this.setReplacedBlock(state);
this.blockIdentifier = GameRegistry.findUniqueIdentifierFor(state.getBlock()); this.registryName = new ResourceLocation(state.getBlock().getRegistryName());
this.meta = state.getBlock().getMetaFromState(state); this.meta = state.getBlock().getMetaFromState(state);
this.flag = 3; this.setFlag(3);
this.nbt = nbt; this.nbt = nbt;
if (DEBUG) 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) public BlockSnapshot(World world, BlockPos pos, IBlockState state, int flag)
{ {
this(world, pos, state); this(world, pos, state);
this.flag = flag; this.setFlag(flag);
} }
/** /**
@ -83,8 +83,8 @@ public class BlockSnapshot implements Serializable
{ {
this.dimId = dimension; this.dimId = dimension;
this.pos = pos.getImmutable(); this.pos = pos.getImmutable();
this.flag = flag; this.setFlag(flag);
this.blockIdentifier = new UniqueIdentifier(modId + ":" + blockName); this.registryName = new ResourceLocation(modId, blockName);
this.meta = meta; this.meta = meta;
this.nbt = nbt; this.nbt = nbt;
} }
@ -115,14 +115,14 @@ public class BlockSnapshot implements Serializable
public IBlockState getCurrentBlock() public IBlockState getCurrentBlock()
{ {
return world.getBlockState(pos); return getWorld().getBlockState(getPos());
} }
public World getWorld() public World getWorld()
{ {
if (this.world == null) if (this.world == null)
{ {
this.world = DimensionManager.getWorld(dimId); this.world = DimensionManager.getWorld(getDimId());
} }
return this.world; return this.world;
} }
@ -131,15 +131,15 @@ public class BlockSnapshot implements Serializable
{ {
if (this.replacedBlock == null) 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; return this.replacedBlock;
} }
public TileEntity getTileEntity() public TileEntity getTileEntity()
{ {
if (nbt != null) if (getNbt() != null)
return TileEntity.createTileEntity(getWorld().getMinecraftServer(), nbt); return TileEntity.createTileEntity(getWorld().getMinecraftServer(), getNbt());
else return null; else return null;
} }
@ -161,7 +161,7 @@ public class BlockSnapshot implements Serializable
{ {
if (force) if (force)
{ {
world.setBlockState(pos, replaced, applyPhysics ? 3 : 2); getWorld().setBlockState(getPos(), replaced, applyPhysics ? 3 : 2);
} }
else else
{ {
@ -169,21 +169,21 @@ public class BlockSnapshot implements Serializable
} }
} }
world.setBlockState(pos, replaced, applyPhysics ? 3 : 2); getWorld().setBlockState(getPos(), replaced, applyPhysics ? 3 : 2);
world.notifyBlockUpdate(pos, current, replaced, applyPhysics ? 3 : 2); getWorld().notifyBlockUpdate(getPos(), current, replaced, applyPhysics ? 3 : 2);
TileEntity te = null; TileEntity te = null;
if (nbt != null) if (getNbt() != null)
{ {
te = world.getTileEntity(pos); te = getWorld().getTileEntity(getPos());
if (te != null) if (te != null)
{ {
te.readFromNBT(nbt); te.readFromNBT(getNbt());
} }
} }
if (DEBUG) 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; return true;
} }
@ -207,12 +207,12 @@ public class BlockSnapshot implements Serializable
world.setBlockState(pos, replaced, applyPhysics ? 3 : 2); world.setBlockState(pos, replaced, applyPhysics ? 3 : 2);
world.notifyBlockUpdate(pos, current, replaced, applyPhysics ? 3 : 2); world.notifyBlockUpdate(pos, current, replaced, applyPhysics ? 3 : 2);
TileEntity te = null; TileEntity te = null;
if (nbt != null) if (getNbt() != null)
{ {
te = world.getTileEntity(pos); te = world.getTileEntity(pos);
if (te != null) if (te != null)
{ {
te.readFromNBT(nbt); te.readFromNBT(getNbt());
} }
} }
@ -225,20 +225,20 @@ public class BlockSnapshot implements Serializable
public void writeToNBT(NBTTagCompound compound) public void writeToNBT(NBTTagCompound compound)
{ {
compound.setString("blockMod", blockIdentifier.modId); compound.setString("blockMod", getRegistryName().getResourceDomain());
compound.setString("blockName", blockIdentifier.name); compound.setString("blockName", getRegistryName().getResourcePath());
compound.setInteger("posX", pos.getX()); compound.setInteger("posX", getPos().getX());
compound.setInteger("posY", pos.getY()); compound.setInteger("posY", getPos().getY());
compound.setInteger("posZ", pos.getZ()); compound.setInteger("posZ", getPos().getZ());
compound.setInteger("flag", flag); compound.setInteger("flag", getFlag());
compound.setInteger("dimension", dimId); compound.setInteger("dimension", getDimId());
compound.setInteger("metadata", meta); 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; return false;
} }
final BlockSnapshot other = (BlockSnapshot) obj; final BlockSnapshot other = (BlockSnapshot) obj;
if (!this.pos.equals(other.pos)) if (!this.getPos().equals(other.getPos()))
{ {
return false; return false;
} }
if (this.meta != other.meta) if (this.getMeta() != other.getMeta())
{ {
return false; return false;
} }
if (this.dimId != other.dimId) if (this.getDimId() != other.getDimId())
{ {
return false; 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; 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; 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; return false;
} }
@ -285,14 +285,24 @@ public class BlockSnapshot implements Serializable
public int hashCode() public int hashCode()
{ {
int hash = 7; int hash = 7;
hash = 73 * hash + this.pos.getX(); hash = 73 * hash + this.getPos().getX();
hash = 73 * hash + this.pos.getY(); hash = 73 * hash + this.getPos().getY();
hash = 73 * hash + this.pos.getZ(); hash = 73 * hash + this.getPos().getZ();
hash = 73 * hash + this.meta; hash = 73 * hash + this.getMeta();
hash = 73 * hash + this.dimId; hash = 73 * hash + this.getDimId();
hash = 73 * hash + (this.nbt != null ? this.nbt.hashCode() : 0); hash = 73 * hash + (this.getNbt() != null ? this.getNbt().hashCode() : 0);
hash = 73 * hash + (this.world != null ? this.world.hashCode() : 0); hash = 73 * hash + (this.getWorld() != null ? this.getWorld().hashCode() : 0);
hash = 73 * hash + (this.blockIdentifier != null ? this.blockIdentifier.hashCode() : 0); hash = 73 * hash + (this.getRegistryName() != null ? this.getRegistryName().hashCode() : 0);
return hash; 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; }
} }

View file

@ -94,7 +94,7 @@ public class ForgeEventFactory
public static MultiPlaceEvent onPlayerMultiBlockPlace(EntityPlayer player, List<BlockSnapshot> blockSnapshots, EnumFacing direction) public static MultiPlaceEvent onPlayerMultiBlockPlace(EntityPlayer player, List<BlockSnapshot> blockSnapshots, EnumFacing direction)
{ {
BlockSnapshot snap = blockSnapshots.get(0); 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); MultiPlaceEvent event = new MultiPlaceEvent(blockSnapshots, placedAgainst, player);
MinecraftForge.EVENT_BUS.post(event); MinecraftForge.EVENT_BUS.post(event);
return event; return event;
@ -102,7 +102,7 @@ public class ForgeEventFactory
public static PlaceEvent onPlayerBlockPlace(EntityPlayer player, BlockSnapshot blockSnapshot, EnumFacing direction) 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); PlaceEvent event = new PlaceEvent(blockSnapshot, placedAgainst, player);
MinecraftForge.EVENT_BUS.post(event); MinecraftForge.EVENT_BUS.post(event);
return event; return event;

View file

@ -154,7 +154,7 @@ public class BlockEvent extends Event
public PlaceEvent(BlockSnapshot blockSnapshot, IBlockState placedAgainst, EntityPlayer player) 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.player = player;
this.itemInHand = player.getHeldItemMainhand(); this.itemInHand = player.getHeldItemMainhand();
this.blockSnapshot = blockSnapshot; this.blockSnapshot = blockSnapshot;

View file

@ -8,9 +8,9 @@ import net.minecraftforge.fml.common.eventhandler.Event;
public class FluidEvent extends Event public class FluidEvent extends Event
{ {
public final FluidStack fluid; private final FluidStack fluid;
public final World world; private final World world;
public final BlockPos pos; private final BlockPos pos;
public FluidEvent(FluidStack fluid, World world, BlockPos pos) public FluidEvent(FluidStack fluid, World world, BlockPos pos)
{ {
@ -19,6 +19,21 @@ public class FluidEvent extends Event
this.pos = pos; 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. * 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 static class FluidFillingEvent extends FluidEvent
{ {
public final IFluidTank tank; private final IFluidTank tank;
public final int amount; private final int amount;
public FluidFillingEvent(FluidStack fluid, World world, BlockPos pos, IFluidTank tank, 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.tank = tank;
this.amount = amount; 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 static class FluidDrainingEvent extends FluidEvent
{ {
public final IFluidTank tank; private final IFluidTank tank;
public final int amount; private final int amount;
public FluidDrainingEvent(FluidStack fluid, World world, BlockPos pos, IFluidTank tank, 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.amount = amount;
this.tank = tank; this.tank = tank;
} }
public IFluidTank getTank()
{
return tank;
}
public int getAmount()
{
return amount;
}
} }
/** /**

View file

@ -36,9 +36,9 @@ import java.util.List;
public class UniversalBucket extends Item implements IFluidContainerItem public class UniversalBucket extends Item implements IFluidContainerItem
{ {
public final int capacity; // how much the bucket holds private final int capacity; // how much the bucket holds
public final ItemStack empty; // empty item to return and recognize when filling private final ItemStack empty; // empty item to return and recognize when filling
public final boolean nbtSensitive; private final boolean nbtSensitive;
public UniversalBucket() public UniversalBucket()
{ {
@ -68,7 +68,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) for (Fluid fluid : FluidRegistry.getRegisteredFluids().values())
{ {
// add all fluids that the bucket can be filled with // 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); ItemStack stack = new ItemStack(this);
if (fill(stack, fs, true) == fs.amount) if (fill(stack, fs, true) == fs.amount)
{ {
@ -83,9 +83,9 @@ public class UniversalBucket extends Item implements IFluidContainerItem
FluidStack fluidStack = getFluid(stack); FluidStack fluidStack = getFluid(stack);
if (fluidStack == null) if (fluidStack == null)
{ {
if(empty != null) if(getEmpty() != null)
{ {
return empty.getDisplayName(); return getEmpty().getDisplayName();
} }
return super.getItemStackDisplayName(stack); return super.getItemStackDisplayName(stack);
} }
@ -132,7 +132,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
player.addStat(StatList.func_188057_b(this)); player.addStat(StatList.func_188057_b(this));
itemstack.stackSize--; 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 // check whether we replace the item or add the empty one to the inventory
if (itemstack.stackSize <= 0) if (itemstack.stackSize <= 0)
@ -210,8 +210,8 @@ public class UniversalBucket extends Item implements IFluidContainerItem
// not for us to handle // not for us to handle
if (event.getEmptyBucket() == null || if (event.getEmptyBucket() == null ||
!event.getEmptyBucket().isItemEqual(empty) || !event.getEmptyBucket().isItemEqual(getEmpty()) ||
(nbtSensitive && ItemStack.areItemStackTagsEqual(event.getEmptyBucket(), empty))) (isNbtSensitive() && ItemStack.areItemStackTagsEqual(event.getEmptyBucket(), getEmpty())))
{ {
return; return;
} }
@ -233,7 +233,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
{ {
FluidStack drained = fluidBlock.drain(world, pos, false); FluidStack drained = fluidBlock.drain(world, pos, false);
// check if it fits exactly // check if it fits exactly
if (drained != null && drained.amount == capacity) if (drained != null && drained.amount == getCapacity())
{ {
// check if the container accepts it // check if the container accepts it
ItemStack filledBucket = new ItemStack(this); ItemStack filledBucket = new ItemStack(this);
@ -262,7 +262,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
public static ItemStack getFilledBucket(UniversalBucket item, Fluid fluid) public static ItemStack getFilledBucket(UniversalBucket item, Fluid fluid)
{ {
ItemStack stack = new ItemStack(item); 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; return stack;
} }
@ -277,7 +277,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
@Override @Override
public int getCapacity(ItemStack container) public int getCapacity(ItemStack container)
{ {
return capacity; return getCapacity();
} }
@Override @Override
@ -290,7 +290,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
} }
// can only fill exact capacity // can only fill exact capacity
if (resource == null || resource.amount != capacity) if (resource == null || resource.amount != getCapacity())
{ {
return 0; return 0;
} }
@ -310,14 +310,14 @@ public class UniversalBucket extends Item implements IFluidContainerItem
resource.writeToNBT(tag); resource.writeToNBT(tag);
container.setTagCompound(tag); container.setTagCompound(tag);
} }
return capacity; return getCapacity();
} }
@Override @Override
public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain)
{ {
// can only drain everything at once // can only drain everything at once
if (maxDrain < capacity) if (maxDrain < getCapacity())
{ {
return null; return null;
} }
@ -325,11 +325,11 @@ public class UniversalBucket extends Item implements IFluidContainerItem
FluidStack fluidStack = getFluid(container); FluidStack fluidStack = getFluid(container);
if (doDrain && fluidStack != null) if (doDrain && fluidStack != null)
{ {
if(empty != null) if(getEmpty() != null)
{ {
container.setItem(empty.getItem()); container.setItem(getEmpty().getItem());
container.setTagCompound(empty.getTagCompound()); container.setTagCompound(getEmpty().getTagCompound());
container.setItemDamage(empty.getItemDamage()); container.setItemDamage(getEmpty().getItemDamage());
} }
else { else {
container.stackSize = 0; container.stackSize = 0;
@ -338,4 +338,19 @@ public class UniversalBucket extends Item implements IFluidContainerItem
return fluidStack; return fluidStack;
} }
public int getCapacity()
{
return capacity;
}
public ItemStack getEmpty()
{
return empty;
}
public boolean isNbtSensitive()
{
return nbtSensitive;
}
} }

View file

@ -29,23 +29,11 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
@HasResult @HasResult
public class ConfigChangedEvent extends Event public class ConfigChangedEvent extends Event
{ {
/** private final String modID;
* The Mod ID of the mod whose configuration just changed. private final boolean isWorldRunning;
*/ private final boolean requiresMcRestart;
public final String modID; private final String configID;
/**
* 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;
public ConfigChangedEvent(String modID, String configID, boolean isWorldRunning, boolean requiresMcRestart) public ConfigChangedEvent(String modID, String configID, boolean isWorldRunning, boolean requiresMcRestart)
{ {
this.modID = modID; this.modID = modID;
@ -53,7 +41,39 @@ public class ConfigChangedEvent extends Event
this.isWorldRunning = isWorldRunning; this.isWorldRunning = isWorldRunning;
this.requiresMcRestart = requiresMcRestart; 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 * 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:<br/> * has been clicked on a GuiConfig screen and the following conditions are met:<br/>

View file

@ -25,10 +25,10 @@ import net.minecraftforge.fml.common.Mod;
*/ */
public class FMLFingerprintViolationEvent extends FMLEvent { public class FMLFingerprintViolationEvent extends FMLEvent {
public final boolean isDirectory; private final boolean isDirectory;
public final Set<String> fingerprints; private final Set<String> fingerprints;
public final File source; private final File source;
public final String expectedFingerprint; private final String expectedFingerprint;
public FMLFingerprintViolationEvent(boolean isDirectory, File source, ImmutableSet<String> fingerprints, String expectedFingerprint) public FMLFingerprintViolationEvent(boolean isDirectory, File source, ImmutableSet<String> fingerprints, String expectedFingerprint)
{ {
@ -38,4 +38,9 @@ public class FMLFingerprintViolationEvent extends FMLEvent {
this.fingerprints = fingerprints; this.fingerprints = fingerprints;
this.expectedFingerprint = expectedFingerprint; this.expectedFingerprint = expectedFingerprint;
} }
public boolean isDirectory() { return isDirectory; }
public Set<String> getFingerprints() { return fingerprints; }
public File getSource() { return source; }
public String getExpectedFingerprint() { return expectedFingerprint; }
} }

View file

@ -125,6 +125,7 @@ public class FMLProxyPacket implements Packet<INetHandler> {
} }
static final int PART_SIZE = 0x1000000 - 0x50; // Make it a constant so that it gets inlined below. 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 static final int MAX_LENGTH = PART_SIZE * 255;
public List<Packet<INetHandlerPlayClient>> toS3FPackets() throws IOException public List<Packet<INetHandlerPlayClient>> toS3FPackets() throws IOException
{ {

View file

@ -90,28 +90,6 @@ public class GameData
return getMain().iBlockRegistry.getObject(new ResourceLocation(modId, name)); 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() protected static GameData getMain()
{ {
return mainData; return mainData;

View file

@ -388,112 +388,12 @@ public class GameRegistry
return GameData.findItem(modId, name); 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 public enum Type
{ {
BLOCK, BLOCK,
ITEM; ITEM;
} }
/**
* Look up the mod identifier data for a block.
* <p/>
* 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.
* <p/>
* 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 * 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. * from the registry. These values can then be referred within mod code directly.

View file

@ -29,7 +29,7 @@ public class FMLInjectionData
static String mccversion; static String mccversion;
static String mcpversion; static String mcpversion;
public static List<String> containers = new ArrayList<String>(); public static final List<String> containers = new ArrayList<String>();
static void build(File mcHome, LaunchClassLoader classLoader) static void build(File mcHome, LaunchClassLoader classLoader)
{ {

View file

@ -28,7 +28,7 @@ public class FMLRelaunchLog {
* Our special logger for logging issues to. We copy various assets from the * Our special logger for logging issues to. We copy various assets from the
* Minecraft logger to achieve a similar appearance. * Minecraft logger to achieve a similar appearance.
*/ */
public static FMLRelaunchLog log = new FMLRelaunchLog(); public static final FMLRelaunchLog log = new FMLRelaunchLog();
static File minecraftHome; static File minecraftHome;
private static boolean configured; private static boolean configured;

View file

@ -9,7 +9,7 @@ import net.minecraft.item.ItemStack;
public class SlotItemHandler extends Slot public class SlotItemHandler extends Slot
{ {
private static IInventory emptyInventory = new InventoryBasic("[Null]", true, 0); private static IInventory emptyInventory = new InventoryBasic("[Null]", true, 0);
public final IItemHandler itemHandler; private final IItemHandler itemHandler;
private final int index; private final int index;
public SlotItemHandler(IItemHandler itemHandler, int index, int xPosition, int yPosition) public SlotItemHandler(IItemHandler itemHandler, int index, int xPosition, int yPosition)
@ -24,21 +24,21 @@ public class SlotItemHandler extends Slot
{ {
if (stack == null) if (stack == null)
return false; 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; return remainder == null || remainder.stackSize < stack.stackSize;
} }
@Override @Override
public ItemStack getStack() public ItemStack getStack()
{ {
return this.itemHandler.getStackInSlot(index); return this.getItemHandler().getStackInSlot(index);
} }
// Override if your IItemHandler does not implement IItemHandlerModifiable // Override if your IItemHandler does not implement IItemHandlerModifiable
@Override @Override
public void putStack(ItemStack stack) public void putStack(ItemStack stack)
{ {
((IItemHandlerModifiable) this.itemHandler).setStackInSlot(index, stack); ((IItemHandlerModifiable) this.getItemHandler()).setStackInSlot(index, stack);
this.onSlotChanged(); this.onSlotChanged();
} }
@ -53,8 +53,8 @@ public class SlotItemHandler extends Slot
{ {
ItemStack maxAdd = stack.copy(); ItemStack maxAdd = stack.copy();
maxAdd.stackSize = maxAdd.getMaxStackSize(); maxAdd.stackSize = maxAdd.getMaxStackSize();
ItemStack currentStack = this.itemHandler.getStackInSlot(index); ItemStack currentStack = this.getItemHandler().getStackInSlot(index);
ItemStack remainder = this.itemHandler.insertItem(index, maxAdd, true); ItemStack remainder = this.getItemHandler().insertItem(index, maxAdd, true);
int current = currentStack == null ? 0 : currentStack.stackSize; int current = currentStack == null ? 0 : currentStack.stackSize;
int added = maxAdd.stackSize - (remainder != null ? remainder.stackSize : 0); int added = maxAdd.stackSize - (remainder != null ? remainder.stackSize : 0);
@ -64,12 +64,17 @@ public class SlotItemHandler extends Slot
@Override @Override
public boolean canTakeStack(EntityPlayer playerIn) public boolean canTakeStack(EntityPlayer playerIn)
{ {
return this.itemHandler.extractItem(index, 1, true) != null; return this.getItemHandler().extractItem(index, 1, true) != null;
} }
@Override @Override
public ItemStack decrStackSize(int amount) public ItemStack decrStackSize(int amount)
{ {
return this.itemHandler.extractItem(index, amount, false); return this.getItemHandler().extractItem(index, amount, false);
}
public IItemHandler getItemHandler()
{
return itemHandler;
} }
} }

View file

@ -6,7 +6,7 @@ import net.minecraftforge.items.IItemHandlerModifiable;
public class EmptyHandler implements IItemHandlerModifiable public class EmptyHandler implements IItemHandlerModifiable
{ {
public static IItemHandler INSTANCE = new EmptyHandler(); public static final IItemHandler INSTANCE = new EmptyHandler();
@Override @Override
public int getSlots() public int getSlots()

View file

@ -7,7 +7,7 @@ import net.minecraftforge.items.ItemHandlerHelper;
public class InvWrapper implements IItemHandlerModifiable public class InvWrapper implements IItemHandlerModifiable
{ {
public final IInventory inv; private final IInventory inv;
public InvWrapper(IInventory inv) public InvWrapper(IInventory inv)
{ {
@ -24,26 +24,26 @@ public class InvWrapper implements IItemHandlerModifiable
InvWrapper that = (InvWrapper) o; InvWrapper that = (InvWrapper) o;
return inv.equals(that.inv); return getInv().equals(that.getInv());
} }
@Override @Override
public int hashCode() public int hashCode()
{ {
return inv.hashCode(); return getInv().hashCode();
} }
@Override @Override
public int getSlots() public int getSlots()
{ {
return inv.getSizeInventory(); return getInv().getSizeInventory();
} }
@Override @Override
public ItemStack getStackInSlot(int slot) public ItemStack getStackInSlot(int slot)
{ {
return inv.getStackInSlot(slot); return getInv().getStackInSlot(slot);
} }
@Override @Override
@ -52,10 +52,10 @@ public class InvWrapper implements IItemHandlerModifiable
if (stack == null) if (stack == null)
return null; return null;
if (!inv.isItemValidForSlot(slot, stack)) if (!getInv().isItemValidForSlot(slot, stack))
return stack; return stack;
ItemStack stackInSlot = inv.getStackInSlot(slot); ItemStack stackInSlot = getInv().getStackInSlot(slot);
int m; int m;
if (stackInSlot != null) if (stackInSlot != null)
@ -63,7 +63,7 @@ public class InvWrapper implements IItemHandlerModifiable
if (!ItemHandlerHelper.canItemStacksStack(stack, stackInSlot)) if (!ItemHandlerHelper.canItemStacksStack(stack, stackInSlot))
return stack; return stack;
m = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit()) - stackInSlot.stackSize; m = Math.min(stack.getMaxStackSize(), getInv().getInventoryStackLimit()) - stackInSlot.stackSize;
if (stack.stackSize <= m) if (stack.stackSize <= m)
{ {
@ -71,8 +71,8 @@ public class InvWrapper implements IItemHandlerModifiable
{ {
ItemStack copy = stack.copy(); ItemStack copy = stack.copy();
copy.stackSize += stackInSlot.stackSize; copy.stackSize += stackInSlot.stackSize;
inv.setInventorySlotContents(slot, copy); getInv().setInventorySlotContents(slot, copy);
inv.markDirty(); getInv().markDirty();
} }
return null; return null;
@ -85,8 +85,8 @@ public class InvWrapper implements IItemHandlerModifiable
{ {
ItemStack copy = stack.splitStack(m); ItemStack copy = stack.splitStack(m);
copy.stackSize += stackInSlot.stackSize; copy.stackSize += stackInSlot.stackSize;
inv.setInventorySlotContents(slot, copy); getInv().setInventorySlotContents(slot, copy);
inv.markDirty(); getInv().markDirty();
return stack; return stack;
} }
else else
@ -98,15 +98,15 @@ public class InvWrapper implements IItemHandlerModifiable
} }
else else
{ {
m = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit()); m = Math.min(stack.getMaxStackSize(), getInv().getInventoryStackLimit());
if (m < stack.stackSize) if (m < stack.stackSize)
{ {
// copy the stack to not modify the original one // copy the stack to not modify the original one
stack = stack.copy(); stack = stack.copy();
if (!simulate) if (!simulate)
{ {
inv.setInventorySlotContents(slot, stack.splitStack(m)); getInv().setInventorySlotContents(slot, stack.splitStack(m));
inv.markDirty(); getInv().markDirty();
return stack; return stack;
} }
else else
@ -119,8 +119,8 @@ public class InvWrapper implements IItemHandlerModifiable
{ {
if (!simulate) if (!simulate)
{ {
inv.setInventorySlotContents(slot, stack); getInv().setInventorySlotContents(slot, stack);
inv.markDirty(); getInv().markDirty();
} }
return null; return null;
} }
@ -134,7 +134,7 @@ public class InvWrapper implements IItemHandlerModifiable
if (amount == 0) if (amount == 0)
return null; return null;
ItemStack stackInSlot = inv.getStackInSlot(slot); ItemStack stackInSlot = getInv().getStackInSlot(slot);
if (stackInSlot == null) if (stackInSlot == null)
return null; return null;
@ -156,8 +156,8 @@ public class InvWrapper implements IItemHandlerModifiable
{ {
int m = Math.min(stackInSlot.stackSize, amount); int m = Math.min(stackInSlot.stackSize, amount);
ItemStack decrStackSize = inv.decrStackSize(slot, m); ItemStack decrStackSize = getInv().decrStackSize(slot, m);
inv.markDirty(); getInv().markDirty();
return decrStackSize; return decrStackSize;
} }
} }
@ -165,6 +165,11 @@ public class InvWrapper implements IItemHandlerModifiable
@Override @Override
public void setStackInSlot(int slot, ItemStack stack) public void setStackInSlot(int slot, ItemStack stack)
{ {
inv.setInventorySlotContents(slot, stack); getInv().setInventorySlotContents(slot, stack);
}
public IInventory getInv()
{
return inv;
} }
} }

View file

@ -6,7 +6,7 @@ import net.minecraft.item.ItemStack;
public class PlayerArmorInvWrapper extends RangedWrapper public class PlayerArmorInvWrapper extends RangedWrapper
{ {
public final InventoryPlayer inventoryPlayer; private final InventoryPlayer inventoryPlayer;
public PlayerArmorInvWrapper(InventoryPlayer inv) public PlayerArmorInvWrapper(InventoryPlayer inv)
{ {
@ -27,10 +27,15 @@ public class PlayerArmorInvWrapper extends RangedWrapper
} }
} }
// check if it's valid for the armor slot // 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 super.insertItem(slot, stack, simulate);
} }
return stack; return stack;
} }
public InventoryPlayer getInventoryPlayer()
{
return inventoryPlayer;
}
} }

View file

@ -10,7 +10,7 @@ import net.minecraft.item.ItemStack;
*/ */
public class PlayerMainInvWrapper extends RangedWrapper public class PlayerMainInvWrapper extends RangedWrapper
{ {
public final InventoryPlayer inventoryPlayer; private final InventoryPlayer inventoryPlayer;
public PlayerMainInvWrapper(InventoryPlayer inv) public PlayerMainInvWrapper(InventoryPlayer inv)
{ {
@ -28,15 +28,20 @@ public class PlayerMainInvWrapper extends RangedWrapper
ItemStack inSlot = getStackInSlot(slot); ItemStack inSlot = getStackInSlot(slot);
if(inSlot != null) if(inSlot != null)
{ {
if (inventoryPlayer.player.worldObj.isRemote) if (getInventoryPlayer().player.worldObj.isRemote)
{ {
inSlot.animationsToGo = 5; inSlot.animationsToGo = 5;
} }
else if(inventoryPlayer.player instanceof EntityPlayerMP) { else if(getInventoryPlayer().player instanceof EntityPlayerMP) {
inventoryPlayer.player.openContainer.detectAndSendChanges(); getInventoryPlayer().player.openContainer.detectAndSendChanges();
} }
} }
} }
return rest; return rest;
} }
public InventoryPlayer getInventoryPlayer()
{
return inventoryPlayer;
}
} }

View file

@ -108,7 +108,7 @@ public class RecipeSorter implements Comparator<IRecipe>
private static Map<String, SortEntry> entries = Maps.newHashMap(); private static Map<String, SortEntry> entries = Maps.newHashMap();
private static Map<Class<?>, Integer> priorities = Maps.newHashMap(); private static Map<Class<?>, Integer> priorities = Maps.newHashMap();
public static RecipeSorter INSTANCE = new RecipeSorter(); public static final RecipeSorter INSTANCE = new RecipeSorter();
private static boolean isDirty = true; private static boolean isDirty = true;
private static SortEntry before = new SortEntry("Before", null, UNKNOWN, ""); private static SortEntry before = new SortEntry("Before", null, UNKNOWN, "");