mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 12:42:26 +00:00
Made some more public fields either private or final.
This commit is contained in:
1 parent
756c58d5cb
commit
75032ebf9c
32 files changed
+355
-331
No files matched your search
@@ -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"))
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public abstract class AbstractBrewingRecipe<T> 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<T> 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<T> 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;
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public class BrewingOreRecipe extends AbstractBrewingRecipe<List<ItemStack>> {
|
||||
@Override
|
||||
public boolean isIngredient(ItemStack stack)
|
||||
{
|
||||
for (ItemStack target : this.ingredient)
|
||||
for (ItemStack target : this.getIngredient())
|
||||
{
|
||||
if (OreDictionary.itemMatches(target, stack, false))
|
||||
{
|
||||
|
||||
@@ -13,6 +13,6 @@ public class BrewingRecipe extends AbstractBrewingRecipe<ItemStack> {
|
||||
@Override
|
||||
public boolean isIngredient(ItemStack stack)
|
||||
{
|
||||
return OreDictionary.itemMatches(this.ingredient, stack, false);
|
||||
return OreDictionary.itemMatches(this.getIngredient(), stack, false);
|
||||
}
|
||||
}
|
||||
@@ -286,7 +286,7 @@ public class ConfigCategory implements Map<String, Property>
|
||||
{
|
||||
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<String, Property>
|
||||
}
|
||||
|
||||
Splitter splitter = Splitter.onPattern("\r?\n");
|
||||
for (String commentLine : splitter.split(prop.comment))
|
||||
for (String commentLine : splitter.split(prop.getComment()))
|
||||
{
|
||||
write(out, pad1, "# ", commentLine);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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("");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
Reference in new issue
Block a user