Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.

Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
This commit is contained in:
Lex Manos committed 2014-11-26 00:00:54 -08:00
1 parent 0e91787efb
commit 53659fca06
410 files changed
+8717 -14103

No files matched your search

@@ -2,7 +2,7 @@ package net.minecraftforge.common;
import java.util.*;
import cpw.mods.fml.common.FMLLog;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraft.init.Blocks;
import net.minecraft.world.biome.*;
import net.minecraftforge.common.util.EnumHelper;
@@ -329,9 +329,9 @@ public class BiomeDictionary
}
}
}
else if(biome.heightVariation <= 0.3F && biome.heightVariation >= 0.0F)
else if(biome.maxHeight <= 0.3F && biome.maxHeight >= 0.0F)
{
if(!biome.isHighHumidity() || biome.rootHeight >= 0.0F)
if(!biome.isHighHumidity() || biome.minHeight >= 0.0F)
{
BiomeDictionary.registerBiomeType(biome, PLAINS);
}
@@ -366,14 +366,14 @@ public class BiomeDictionary
BiomeDictionary.registerBiomeType(biome, DENSE);
}
if (biome.isHighHumidity() && biome.rootHeight < 0.0F && (biome.heightVariation <= 0.3F && biome.heightVariation >= 0.0F))
if (biome.isHighHumidity() && biome.minHeight < 0.0F && (biome.maxHeight <= 0.3F && biome.maxHeight >= 0.0F))
{
BiomeDictionary.registerBiomeType(biome, SWAMP);
}
if (biome.rootHeight <= -0.5F)
if (biome.minHeight <= -0.5F)
{
if (biome.heightVariation == 0.0F)
if (biome.maxHeight == 0.0F)
{
BiomeDictionary.registerBiomeType(biome, RIVER);
}
@@ -383,12 +383,12 @@ public class BiomeDictionary
}
}
if (biome.heightVariation >= 0.4F && biome.heightVariation < 1.5F)
if (biome.maxHeight >= 0.4F && biome.maxHeight < 1.5F)
{
BiomeDictionary.registerBiomeType(biome, HILLS);
}
if (biome.heightVariation >= 1.5F)
if (biome.maxHeight >= 1.5F)
{
BiomeDictionary.registerBiomeType(biome, MOUNTAIN);
}
@@ -19,23 +19,11 @@ import net.minecraftforge.common.util.EnumHelper;
public class BiomeManager
{
private static TrackedList<BiomeEntry>[] biomes = setupBiomes();
/*
* These lists should no longer be accessed directly. Instead, use the appropriate add, remove and get methods within this class.
*/
@Deprecated
public static List<BiomeEntry> desertBiomes = biomes[BiomeType.DESERT.ordinal()];
@Deprecated
public static List<BiomeEntry> warmBiomes = biomes[BiomeType.WARM.ordinal()];
@Deprecated
public static List<BiomeEntry> coolBiomes = biomes[BiomeType.COOL.ordinal()];
@Deprecated
public static List<BiomeEntry> icyBiomes = biomes[BiomeType.ICY.ordinal()];
private static boolean isModded = false;
public static List<BiomeGenBase> oceanBiomes = new ArrayList<BiomeGenBase>();
public static ArrayList<BiomeGenBase> strongHoldBiomes = new ArrayList<BiomeGenBase>();
public static ArrayList<BiomeGenBase> strongHoldBiomesBlackList = new ArrayList<BiomeGenBase>();
@@ -45,19 +33,19 @@ public class BiomeManager
oceanBiomes.add(BiomeGenBase.deepOcean);
oceanBiomes.add(BiomeGenBase.frozenOcean);
}
private static TrackedList<BiomeEntry>[] setupBiomes()
{
TrackedList<BiomeEntry>[] currentBiomes = new TrackedList[BiomeType.values().length];
List list = new ArrayList();
list.add(new BiomeEntry(BiomeGenBase.forest, 10));
list.add(new BiomeEntry(BiomeGenBase.roofedForest, 10));
list.add(new BiomeEntry(BiomeGenBase.extremeHills, 10));
list.add(new BiomeEntry(BiomeGenBase.plains, 10));
list.add(new BiomeEntry(BiomeGenBase.birchForest, 10));
list.add(new BiomeEntry(BiomeGenBase.swampland, 10));
currentBiomes[BiomeType.WARM.ordinal()] = new TrackedList(list);
list.clear();
@@ -65,7 +53,7 @@ public class BiomeManager
list.add(new BiomeEntry(BiomeGenBase.extremeHills, 10));
list.add(new BiomeEntry(BiomeGenBase.taiga, 10));
list.add(new BiomeEntry(BiomeGenBase.plains, 10));
currentBiomes[BiomeType.COOL.ordinal()] = new TrackedList(list);
list.clear();
@@ -74,9 +62,9 @@ public class BiomeManager
currentBiomes[BiomeType.ICY.ordinal()] = new TrackedList(list);
list.clear();
currentBiomes[BiomeType.DESERT.ordinal()] = new TrackedList(list);
return currentBiomes;
}
@@ -133,67 +121,67 @@ public class BiomeManager
WorldChunkManager.allowedBiomes.remove(biome);
}
}
public static void addBiome(BiomeType type, BiomeEntry entry)
{
isModded = true;
int idx = type.ordinal();
List<BiomeEntry> list = idx > biomes.length ? null : biomes[idx];
if (list != null) list.add(entry);
}
public static void removeBiome(BiomeType type, BiomeEntry entry)
{
isModded = true;
int idx = type.ordinal();
List<BiomeEntry> list = idx > biomes.length ? null : biomes[idx];
if (list != null && list.contains(entry))
{
list.remove(entry);
}
}
public static ImmutableList<BiomeEntry> getBiomes(BiomeType type)
{
int idx = type.ordinal();
List<BiomeEntry> list = idx > biomes.length ? null : biomes[idx];
return list != null ? ImmutableList.copyOf(list) : null;
}
public static boolean isTypeListModded(BiomeType type)
{
int idx = type.ordinal();
TrackedList<BiomeEntry> list = idx > biomes.length ? null : biomes[idx];
if (list != null) return list.isModded();
return false;
}
public static enum BiomeType
{
DESERT, WARM, COOL, ICY;
public static BiomeType getType(String name)
{
name = name.toUpperCase();
for (BiomeType t : values())
{
if (t.name().equals(name)) return t;
}
BiomeType ret = EnumHelper.addEnum(BiomeType.class, name, BiomeType.class);
if (ret.ordinal() >= biomes.length)
{
biomes = Arrays.copyOf(biomes, ret.ordinal());
}
return ret;
}
}
@@ -201,89 +189,89 @@ public class BiomeManager
public static class BiomeEntry extends WeightedRandom.Item
{
public final BiomeGenBase biome;
public BiomeEntry(BiomeGenBase biome, int weight)
{
super(weight);
this.biome = biome;
}
}
private static class TrackedList<E> extends ArrayList<E>
{
private boolean isModded = false;
public TrackedList(Collection<? extends E> c)
public TrackedList(Collection<? extends E> c)
{
super(c);
}
@Override
public E set(int index, E element)
public E set(int index, E element)
{
isModded = true;
return super.set(index, element);
}
@Override
public boolean add(E e)
public boolean add(E e)
{
isModded = true;
return super.add(e);
}
@Override
public void add(int index, E element)
public void add(int index, E element)
{
isModded = true;
super.add(index, element);
}
@Override
public E remove(int index)
public E remove(int index)
{
isModded = true;
return super.remove(index);
}
@Override
public boolean remove(Object o)
public boolean remove(Object o)
{
isModded = true;
return super.remove(o);
}
@Override
public void clear()
public void clear()
{
isModded = true;
super.clear();
}
@Override
public boolean addAll(Collection<? extends E> c)
public boolean addAll(Collection<? extends E> c)
{
isModded = true;
return super.addAll(c);
}
@Override
public boolean addAll(int index, Collection<? extends E> c)
public boolean addAll(int index, Collection<? extends E> c)
{
isModded = true;
return super.addAll(index, c);
}
@Override
public boolean removeAll(Collection<?> c)
public boolean removeAll(Collection<?> c)
{
isModded = true;
return super.removeAll(c);
}
@Override
public boolean retainAll(Collection<?> c)
public boolean retainAll(Collection<?> c)
{
isModded = true;
return super.retainAll(c);
@@ -1,7 +1,7 @@
package net.minecraftforge.common;
import java.util.*;
import com.google.common.collect.ImmutableList;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -47,27 +47,23 @@ public class ChestGenHooks
}
hasInit = true;
// This causes the classes static initializers to run
new WorldGenDungeons();
new DesertPyramid();
new JunglePyramid();
new StructureMineshaftPieces();
new StructureOceanMonument();
new StructureStrongholdPieces.ChestCorridor();
new StructureStrongholdPieces.Library();
new StructureStrongholdPieces.RoomCrossing();
new StructureVillagePieces.House2();
WorldServer.fillChestHook();
}
addInfo(MINESHAFT_CORRIDOR, StructureMineshaftPieces.mineshaftChestContents, 3, 7);
addInfo(PYRAMID_DESERT_CHEST, DesertPyramid.itemsToGenerateInTemple, 2, 7);
addInfo(PYRAMID_JUNGLE_CHEST, JunglePyramid.junglePyramidsChestContents, 2, 7);
addInfo(PYRAMID_JUNGLE_DISPENSER, JunglePyramid.junglePyramidsDispenserContents, 2, 2);
addInfo(STRONGHOLD_CORRIDOR, ChestCorridor.strongholdChestContents, 2, 4);
addInfo(STRONGHOLD_LIBRARY, Library.strongholdLibraryChestContents, 1, 5);
addInfo(STRONGHOLD_CROSSING, RoomCrossing.strongholdRoomCrossingChestContents, 1, 5);
addInfo(VILLAGE_BLACKSMITH, House2.villageBlacksmithChestContents, 3, 9);
addInfo(BONUS_CHEST, WorldServer.bonusChestContent, 10, 10);
addInfo(DUNGEON_CHEST, WorldGenDungeons.field_111189_a, 8, 8);
ItemStack book = new ItemStack(Items.enchanted_book, 1, 0);
WeightedRandomChestContent tmp = new WeightedRandomChestContent(book, 1, 1, 1);
getInfo(MINESHAFT_CORRIDOR ).addItem(tmp);
getInfo(PYRAMID_DESERT_CHEST).addItem(tmp);
getInfo(PYRAMID_JUNGLE_CHEST).addItem(tmp);
getInfo(STRONGHOLD_CORRIDOR ).addItem(tmp);
getInfo(STRONGHOLD_LIBRARY ).addItem(new WeightedRandomChestContent(book, 1, 5, 2));
getInfo(STRONGHOLD_CROSSING ).addItem(tmp);
getInfo(DUNGEON_CHEST ).addItem(tmp);
// INTERNAL DO NO USE
public static void init(String category, List items, int min, int max)
{
chestInfo.put(category, new ChestGenHooks(category, (List<WeightedRandomChestContent>)items, min, max));
}
static void addDungeonLoot(ChestGenHooks dungeon, ItemStack item, int weight, int min, int max)
@@ -75,11 +71,6 @@ public class ChestGenHooks
dungeon.addItem(new WeightedRandomChestContent(item, min, max, weight));
}
private static void addInfo(String category, WeightedRandomChestContent[] items, int min, int max)
{
chestInfo.put(category, new ChestGenHooks(category, items, min, max));
}
/**
* Retrieves, or creates the info class for the specified category.
*
@@ -134,7 +125,7 @@ public class ChestGenHooks
}
//shortcut functions, See the non-static versions below
public static WeightedRandomChestContent[] getItems(String category, Random rnd){ return getInfo(category).getItems(rnd); }
public static List<WeightedRandomChestContent> getItems(String category, Random rnd){ return getInfo(category).getItems(rnd); }
public static int getCount(String category, Random rand){ return getInfo(category).getCount(rand); }
public static void addItem(String category, WeightedRandomChestContent item){ getInfo(category).addItem(item); }
public static void removeItem(String category, ItemStack item){ getInfo(category).removeItem(item); }
@@ -150,7 +141,7 @@ public class ChestGenHooks
this.category = category;
}
public ChestGenHooks(String category, WeightedRandomChestContent[] items, int min, int max)
public ChestGenHooks(String category, List<WeightedRandomChestContent> items, int min, int max)
{
this(category);
for (WeightedRandomChestContent item : items)
@@ -195,7 +186,7 @@ public class ChestGenHooks
*
* @return The random objects
*/
public WeightedRandomChestContent[] getItems(Random rnd)
public List<WeightedRandomChestContent> getItems(Random rnd)
{
ArrayList<WeightedRandomChestContent> ret = new ArrayList<WeightedRandomChestContent>();
@@ -213,7 +204,7 @@ public class ChestGenHooks
}
}
return ret.toArray(new WeightedRandomChestContent[ret.size()]);
return ret;
}
/**
@@ -236,8 +227,7 @@ public class ChestGenHooks
*/
public ItemStack getOneItem(Random rand)
{
WeightedRandomChestContent[] items = getItems(rand);
WeightedRandomChestContent item = (WeightedRandomChestContent)WeightedRandom.getRandomItem(rand, items);
WeightedRandomChestContent item = (WeightedRandomChestContent)WeightedRandom.getRandomItem(rand, getItems(rand));
ItemStack[] stacks = ChestGenHooks.generateStacks(rand, item.theItemId, item.theMinimumChanceToGenerateItem, item.theMaximumChanceToGenerateItem);
return (stacks.length > 0 ? stacks[0] : null);
}
@@ -17,8 +17,8 @@ import com.google.common.collect.HashMultiset;
import com.google.common.collect.Lists;
import com.google.common.collect.MapMaker;
import com.google.common.collect.Multiset;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.MinecraftException;
@@ -242,7 +242,7 @@ public class DimensionManager
ISaveHandler savehandler = overworld.getSaveHandler();
WorldSettings worldSettings = new WorldSettings(overworld.getWorldInfo());
WorldServer world = (dim == 0 ? overworld : new WorldServerMulti(mcServer, savehandler, overworld.getWorldInfo().getWorldName(), dim, worldSettings, overworld, mcServer.theProfiler));
WorldServer world = (dim == 0 ? overworld : new WorldServerMulti(mcServer, savehandler, dim, overworld, mcServer.theProfiler));
world.addWorldAccess(new WorldManager(mcServer, world));
MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world));
if (!mcServer.isSinglePlayer())
@@ -250,7 +250,7 @@ public class DimensionManager
world.getWorldInfo().setGameType(mcServer.getGameType());
}
mcServer.func_147139_a(mcServer.func_147135_j());
mcServer.setDifficultyForAllWorlds(mcServer.getDifficulty());
}
public static WorldServer getWorld(int id)
@@ -425,4 +425,4 @@ public class DimensionManager
return null;
}
}
}
}
@@ -43,19 +43,19 @@ public class FishingHooks
if (chance < junkChance)
{
return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, junk)).func_150708_a(rand);
return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, junk)).getItemStack(rand);
}
chance -= junkChance;
if (chance < treasureChance)
{
return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, treasure)).func_150708_a(rand);
return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, treasure)).getItemStack(rand);
}
chance -= treasureChance;
// this is done in EntityFishHook.func_146033_f. more loot types expected?
{
return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, fish)).func_150708_a(rand);
return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, fish)).getItemStack(rand);
}
}
@@ -93,15 +93,15 @@ public class FishingHooks
static
{
fish.addAll(EntityFishHook.field_146036_f);
junk.addAll(EntityFishHook.field_146039_d);
treasure.addAll(EntityFishHook.field_146041_e);
fish.addAll(EntityFishHook.FISH);
junk.addAll(EntityFishHook.JUNK);
treasure.addAll(EntityFishHook.VALUABLES);
}
public static enum FishableCategory
{
JUNK(StatList.field_151183_A),
TREASURE(StatList.field_151184_B),
JUNK(StatList.junkFishedStat),
TREASURE(StatList.treasureFishedStat),
FISH(StatList.fishCaughtStat);
public final StatBase stat;
@@ -111,4 +111,4 @@ public class FishingHooks
this.stat = stat;
}
}
}
}
@@ -8,14 +8,13 @@ package net.minecraftforge.common;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.apache.logging.log4j.Level;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ArrayListMultimap;
@@ -33,16 +32,16 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.entity.Entity;
import net.minecraft.util.ClassInheritanceMultiMap;
import net.minecraft.util.MathHelper;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@@ -895,7 +894,7 @@ public class ForgeChunkManager
public static void putDormantChunk(long coords, Chunk chunk)
{
Cache<Long, Chunk> cache = dormantChunkCache.get(chunk.worldObj);
Cache<Long, Chunk> cache = dormantChunkCache.get(chunk.getWorld());
if (cache != null)
{
cache.put(coords, chunk);
@@ -913,11 +912,12 @@ public class ForgeChunkManager
Chunk chunk = cache.getIfPresent(coords);
if (chunk != null)
{
for (List<Entity> eList : (List<Entity>[])chunk.entityLists)
for (ClassInheritanceMultiMap eList : chunk.getEntityLists())
{
for (Entity e: eList)
Iterator<Entity> itr = (Iterator<Entity>)eList.iterator();
while (itr.hasNext())
{
e.resetEntityId();
(itr.next()).resetEntityId();
}
}
}
@@ -1,12 +1,23 @@
package net.minecraftforge.common;
import static net.minecraft.init.Blocks.diamond_block;
import static net.minecraft.init.Blocks.diamond_ore;
import static net.minecraft.init.Blocks.emerald_block;
import static net.minecraft.init.Blocks.emerald_ore;
import static net.minecraft.init.Blocks.gold_block;
import static net.minecraft.init.Blocks.gold_ore;
import static net.minecraft.init.Blocks.lit_redstone_ore;
import static net.minecraft.init.Blocks.redstone_ore;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Set;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
@@ -16,6 +27,7 @@ import net.minecraft.init.Items;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerRepair;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemAxe;
@@ -25,6 +37,8 @@ import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S23PacketBlockChange;
@@ -32,14 +46,20 @@ import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityNote;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
import net.minecraft.util.WeightedRandom;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.WorldSettings;
import net.minecraft.world.WorldSettings.GameType;
import net.minecraft.world.gen.feature.WorldGeneratorBonusChest;
import net.minecraftforge.common.util.BlockSnapshot;
import net.minecraftforge.event.AnvilUpdateEvent;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.ServerChatEvent;
@@ -52,11 +72,15 @@ import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.event.entity.living.LivingFallEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent;
import net.minecraftforge.event.entity.player.AnvilRepairEvent;
import net.minecraftforge.event.entity.player.AttackEntityEvent;
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.NoteBlockEvent;
import static net.minecraft.init.Blocks.*;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
public class ForgeHooks
{
@@ -71,9 +95,9 @@ public class ForgeHooks
}
static final List<SeedEntry> seedList = new ArrayList<SeedEntry>();
public static ItemStack getGrassSeed(World world)
public static ItemStack getGrassSeed(Random rand)
{
SeedEntry entry = (SeedEntry)WeightedRandom.getRandomItem(world.rand, seedList);
SeedEntry entry = (SeedEntry)WeightedRandom.getRandomItem(rand, seedList);
if (entry == null || entry.seed == null)
{
return null;
@@ -84,7 +108,7 @@ public class ForgeHooks
private static boolean toolInit = false;
//static HashSet<List> toolEffectiveness = new HashSet<List>();
public static boolean canHarvestBlock(Block block, EntityPlayer player, int metadata)
public static boolean canHarvestBlock(Block block, EntityPlayer player, IBlockAccess world, BlockPos pos)
{
if (block.getMaterial().isToolNotRequired())
{
@@ -92,7 +116,9 @@ public class ForgeHooks
}
ItemStack stack = player.inventory.getCurrentItem();
String tool = block.getHarvestTool(metadata);
IBlockState state = world.getBlockState(pos);
state = state.getBlock().getActualState(state, world, pos);
String tool = block.getHarvestTool(state);
if (stack == null || tool == null)
{
return player.canHarvestBlock(block);
@@ -104,40 +130,43 @@ public class ForgeHooks
return player.canHarvestBlock(block);
}
return toolLevel >= block.getHarvestLevel(metadata);
return toolLevel >= block.getHarvestLevel(state);
}
public static boolean canToolHarvestBlock(Block block, int metadata, ItemStack stack)
public static boolean canToolHarvestBlock(IBlockAccess world, BlockPos pos, ItemStack stack)
{
String tool = block.getHarvestTool(metadata);
IBlockState state = world.getBlockState(pos);
state = state.getBlock().getActualState(state, world, pos);
String tool = state.getBlock().getHarvestTool(state);
if (stack == null || tool == null) return false;
return stack.getItem().getHarvestLevel(stack, tool) >= block.getHarvestLevel(metadata);
return stack.getItem().getHarvestLevel(stack, tool) >= state.getBlock().getHarvestLevel(state);
}
public static float blockStrength(Block block, EntityPlayer player, World world, int x, int y, int z)
public static float blockStrength(IBlockState state, EntityPlayer player, World world, BlockPos pos)
{
int metadata = world.getBlockMetadata(x, y, z);
float hardness = block.getBlockHardness(world, x, y, z);
float hardness = state.getBlock().getBlockHardness(world, pos);
if (hardness < 0.0F)
{
return 0.0F;
}
if (!canHarvestBlock(block, player, metadata))
if (!canHarvestBlock(state.getBlock(), player, world, pos))
{
return player.getBreakSpeed(block, true, metadata, x, y, z) / hardness / 100F;
return player.getBreakSpeed(state, pos) / hardness / 100F;
}
else
{
return player.getBreakSpeed(block, false, metadata, x, y, z) / hardness / 30F;
return player.getBreakSpeed(state, pos) / hardness / 30F;
}
}
public static boolean isToolEffective(ItemStack stack, Block block, int metadata)
public static boolean isToolEffective(IBlockAccess world, BlockPos pos, ItemStack stack)
{
IBlockState state = world.getBlockState(pos);
state = state.getBlock().getActualState(state, world, pos);
for (String type : stack.getItem().getToolClasses(stack))
{
if (block.isToolEffective(type, metadata))
if (state.getBlock().isToolEffective(type, state))
return true;
}
return false;
@@ -211,20 +240,21 @@ public class ForgeHooks
{
ItemStack result = null;
boolean isCreative = player.capabilities.isCreativeMode;
TileEntity te = null;
if (target.typeOfHit == MovingObjectType.BLOCK)
{
int x = target.blockX;
int y = target.blockY;
int z = target.blockZ;
Block block = world.getBlock(x, y, z);
IBlockState state = world.getBlockState(target.func_178782_a());
if (block.isAir(world, x, y, z))
if (state.getBlock().isAir(world, target.func_178782_a()))
{
return false;
}
result = block.getPickBlock(target, world, x, y, z, player);
if (isCreative && GuiScreen.isCtrlKeyDown())
te = world.getTileEntity(target.func_178782_a());
result = state.getBlock().getPickBlock(target, world, target.func_178782_a());
}
else
{
@@ -241,6 +271,20 @@ public class ForgeHooks
return false;
}
if (te != null)
{
NBTTagCompound nbt = new NBTTagCompound();
te.writeToNBT(nbt);
result.setTagInfo("BlockEntityTag", nbt);
NBTTagCompound display = new NBTTagCompound();
result.setTagInfo("display", display);
NBTTagList lore = new NBTTagList();
display.setTag("Lore", lore);
lore.appendTag(new NBTTagString("(+NBT)"));
}
for (int x = 0; x < 9; x++)
{
ItemStack stack = player.inventory.getStackInSlot(x);
@@ -296,26 +340,28 @@ public class ForgeHooks
return MinecraftForge.EVENT_BUS.post(new LivingDeathEvent(entity, src));
}
public static boolean onLivingDrops(EntityLivingBase entity, DamageSource source, ArrayList<EntityItem> drops, int lootingLevel, boolean recentlyHit, int specialDropValue)
public static boolean onLivingDrops(EntityLivingBase entity, DamageSource source, ArrayList<EntityItem> drops, int lootingLevel, boolean recentlyHit)
{
return MinecraftForge.EVENT_BUS.post(new LivingDropsEvent(entity, source, drops, lootingLevel, recentlyHit, specialDropValue));
return MinecraftForge.EVENT_BUS.post(new LivingDropsEvent(entity, source, drops, lootingLevel, recentlyHit));
}
public static float onLivingFall(EntityLivingBase entity, float distance)
public static float[] onLivingFall(EntityLivingBase entity, float distance, float damageMultiplier)
{
LivingFallEvent event = new LivingFallEvent(entity, distance);
return (MinecraftForge.EVENT_BUS.post(event) ? 0.0f : event.distance);
LivingFallEvent event = new LivingFallEvent(entity, distance, damageMultiplier);
return (MinecraftForge.EVENT_BUS.post(event) ? null : new float[]{event.distance, event.damageMultiplier});
}
public static boolean isLivingOnLadder(Block block, World world, int x, int y, int z, EntityLivingBase entity)
public static boolean isLivingOnLadder(Block block, World world, BlockPos pos, EntityLivingBase entity)
{
boolean isSpectator = (entity instanceof EntityPlayer && ((EntityPlayer)entity).func_175149_v());
if (isSpectator) return false;
if (!ForgeModContainer.fullBoundingBoxLadders)
{
return block != null && block.isLadder(world, x, y, z, entity);
return block != null && block.isLadder(world, pos, entity) && isSpectator;
}
else
{
AxisAlignedBB bb = entity.boundingBox;
AxisAlignedBB bb = entity.getEntityBoundingBox();
int mX = MathHelper.floor_double(bb.minX);
int mY = MathHelper.floor_double(bb.minY);
int mZ = MathHelper.floor_double(bb.minZ);
@@ -325,8 +371,8 @@ public class ForgeHooks
{
for (int z2 = mZ; z2 < bb.maxZ; z2++)
{
block = world.getBlock(x2, y2, z2);
if (block != null && block.isLadder(world, x2, y2, z2, entity))
BlockPos tmp = new BlockPos(x2, y2, z2);
if (world.getBlockState(tmp).getBlock().isLadder(world, tmp, entity))
{
return true;
}
@@ -364,9 +410,9 @@ public class ForgeHooks
return event.entityItem;
}
public static float getEnchantPower(World world, int x, int y, int z)
public static float getEnchantPower(World world, BlockPos pos)
{
return world.getBlock(x, y, z).getEnchantPowerBonus(world, x, y, z);
return world.getBlockState(pos).getBlock().getEnchantPowerBonus(world, pos);
}
public static ChatComponentTranslation onServerChatEvent(NetHandlerPlayServer net, String raw, ChatComponentTranslation comp)
@@ -386,32 +432,37 @@ public class ForgeHooks
return event.getResult() == Event.Result.DEFAULT ? event.canInteractWith : event.getResult() == Event.Result.ALLOW ? true : false;
}
public static BlockEvent.BreakEvent onBlockBreakEvent(World world, GameType gameType, EntityPlayerMP entityPlayer, int x, int y, int z)
public static int onBlockBreakEvent(World world, GameType gameType, EntityPlayerMP entityPlayer, BlockPos pos)
{
// Logic from tryHarvestBlock for pre-canceling the event
boolean preCancelEvent = false;
if (gameType.isAdventure() && !entityPlayer.isCurrentToolAdventureModeExempt(x, y, z))
{
if (gameType.isCreative() && entityPlayer.getHeldItem() != null && entityPlayer.getHeldItem().getItem() instanceof ItemSword)
preCancelEvent = true;
}
else if (gameType.isCreative() && entityPlayer.getHeldItem() != null && entityPlayer.getHeldItem().getItem() instanceof ItemSword)
if (gameType.isAdventure())
{
preCancelEvent = true;
if (gameType == WorldSettings.GameType.SPECTATOR)
preCancelEvent = true;
if (!entityPlayer.func_175142_cm())
{
ItemStack itemstack = entityPlayer.getCurrentEquippedItem();
if (itemstack == null || !itemstack.canDestroy(world.getBlockState(pos).getBlock()))
preCancelEvent = true;
}
}
// Tell client the block is gone immediately then process events
if (world.getTileEntity(x, y, z) == null)
if (world.getTileEntity(pos) == null)
{
S23PacketBlockChange packet = new S23PacketBlockChange(x, y, z, world);
packet.field_148883_d = Blocks.air;
packet.field_148884_e = 0;
S23PacketBlockChange packet = new S23PacketBlockChange(world, pos);
packet.field_148883_d = Blocks.air.getDefaultState();
entityPlayer.playerNetServerHandler.sendPacket(packet);
}
// Post the block break event
Block block = world.getBlock(x, y, z);
int blockMetadata = world.getBlockMetadata(x, y, z);
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(x, y, z, world, block, blockMetadata, entityPlayer);
IBlockState state = world.getBlockState(pos);
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, state, entityPlayer);
event.setCanceled(preCancelEvent);
MinecraftForge.EVENT_BUS.post(event);
@@ -419,10 +470,10 @@ public class ForgeHooks
if (event.isCanceled())
{
// Let the client know the block still exists
entityPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
entityPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(world, pos));
// Update any tile entity data for this block
TileEntity tileentity = world.getTileEntity(x, y, z);
TileEntity tileentity = world.getTileEntity(pos);
if (tileentity != null)
{
Packet pkt = tileentity.getDescriptionPacket();
@@ -432,10 +483,10 @@ public class ForgeHooks
}
}
}
return event;
return event.isCanceled() ? -1 : event.getExpToDrop();
}
public static boolean onPlaceItemIntoWorld(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
public static boolean onPlaceItemIntoWorld(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
// handle all placement events here
int meta = itemstack.getItemDamage();
@@ -451,7 +502,7 @@ public class ForgeHooks
world.captureBlockSnapshots = true;
}
boolean flag = itemstack.getItem().onItemUse(itemstack, player, world, x, y, z, side, hitX, hitY, hitZ);
boolean flag = itemstack.getItem().onItemUse(itemstack, player, world, pos, side, hitX, hitY, hitZ);
world.captureBlockSnapshots = false;
if (flag)
@@ -465,7 +516,7 @@ public class ForgeHooks
newNBT = (NBTTagCompound)itemstack.getTagCompound().copy();
}
net.minecraftforge.event.world.BlockEvent.PlaceEvent placeEvent = null;
List<net.minecraftforge.common.util.BlockSnapshot> blockSnapshots = (List<net.minecraftforge.common.util.BlockSnapshot>) world.capturedBlockSnapshots.clone();
List<net.minecraftforge.common.util.BlockSnapshot> blockSnapshots = (List<BlockSnapshot>)world.capturedBlockSnapshots.clone();
world.capturedBlockSnapshots.clear();
// make sure to set pre-placement item data for event
@@ -477,11 +528,11 @@ public class ForgeHooks
}
if (blockSnapshots.size() > 1)
{
placeEvent = ForgeEventFactory.onPlayerMultiBlockPlace(player, blockSnapshots, net.minecraftforge.common.util.ForgeDirection.getOrientation(side));
placeEvent = ForgeEventFactory.onPlayerMultiBlockPlace(player, blockSnapshots, side);
}
else if (blockSnapshots.size() == 1)
{
placeEvent = ForgeEventFactory.onPlayerBlockPlace(player, blockSnapshots.get(0), net.minecraftforge.common.util.ForgeDirection.getOrientation(side));
placeEvent = ForgeEventFactory.onPlayerBlockPlace(player, blockSnapshots.get(0), side);
}
if (placeEvent != null && (placeEvent.isCanceled()))
@@ -505,21 +556,17 @@ public class ForgeHooks
itemstack.setTagCompound(newNBT);
}
for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : blockSnapshots)
for (BlockSnapshot snap : blockSnapshots)
{
int blockX = blocksnapshot.x;
int blockY = blocksnapshot.y;
int blockZ = blocksnapshot.z;
int metadata = world.getBlockMetadata(blockX, blockY, blockZ);
int updateFlag = blocksnapshot.flag;
Block oldBlock = blocksnapshot.replacedBlock;
Block newBlock = world.getBlock(blockX, blockY, blockZ);
if (newBlock != null && !(newBlock.hasTileEntity(metadata))) // Containers get placed automatically
int updateFlag = snap.flag;
IBlockState oldBlock = snap.replacedBlock;
IBlockState newBlock = world.getBlockState(snap.pos);
if (newBlock != null && !(newBlock.getBlock().hasTileEntity(newBlock))) // Containers get placed automatically
{
newBlock.onBlockAdded(world, blockX, blockY, blockZ);
newBlock.getBlock().onBlockAdded(world, snap.pos, newBlock);
}
world.markAndNotifyBlock(blockX, blockY, blockZ, null, oldBlock, newBlock, updateFlag);
world.markAndNotifyBlock(snap.pos, null, oldBlock, newBlock, updateFlag);
}
player.addStat(StatList.objectUseStats[Item.getIdFromItem(itemstack.getItem())], 1);
}
@@ -537,7 +584,7 @@ public class ForgeHooks
outputSlot.setInventorySlotContents(0, e.output);
container.maximumCost = e.cost;
container.stackSizeToBeUsedInRepair = e.materialCost;
container.materialCost = e.materialCost;
return false;
}
@@ -550,7 +597,7 @@ public class ForgeHooks
public static boolean onNoteChange(TileEntityNote te, byte old)
{
NoteBlockEvent.Change e = new NoteBlockEvent.Change(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, te.getBlockMetadata(), old, te.note);
NoteBlockEvent.Change e = new NoteBlockEvent.Change(te.getWorld(), te.getPos(), te.getWorld().getBlockState(te.getPos()), old, te.note);
if (MinecraftForge.EVENT_BUS.post(e))
{
te.note = old;
@@ -559,4 +606,90 @@ public class ForgeHooks
te.note = (byte)e.getVanillaNoteId();
return true;
}
/**
* Default implementation of IRecipe.func_179532_b {getRemainingItems} because
* this is just copy pasted over a lot of recipes.
*
* Another use case for java 8 but sadly we can't use it!
*
* @param inv Crafting inventory
* @return Crafting inventory contents after the recipe.
*/
public static ItemStack[] defaultRecipeGetRemainingItems(InventoryCrafting inv)
{
ItemStack[] ret = new ItemStack[inv.getSizeInventory()];
for (int i = 0; i < ret.length; i++)
{
ret[i] = getContainerItem(inv.getStackInSlot(i));
}
return ret;
}
private static ThreadLocal<EntityPlayer> craftingPlayer = new ThreadLocal<EntityPlayer>();
public static void setCraftingPlayer(EntityPlayer player)
{
craftingPlayer.set(player);
}
public static EntityPlayer getCraftingPlayer()
{
return craftingPlayer.get();
}
public static ItemStack getContainerItem(ItemStack stack)
{
if (stack == null) return null;
if (stack.getItem().hasContainerItem(stack))
{
stack = stack.getItem().getContainerItem(stack);
if (stack != null && stack.isItemStackDamageable() && stack.getMetadata() > stack.getMaxDamage())
{
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(craftingPlayer.get(), stack));
return null;
}
return stack;
}
return null;
}
public static WorldGeneratorBonusChest getBonusChest(Random rand)
{
return new WorldGeneratorBonusChest(ChestGenHooks.getItems(ChestGenHooks.BONUS_CHEST, rand), ChestGenHooks.getCount(ChestGenHooks.BONUS_CHEST, rand));
}
public static boolean isInsideOfMaterial(Material material, Entity entity, BlockPos pos)
{
IBlockState state = entity.worldObj.getBlockState(pos);
Block block = state.getBlock();
double eyes = entity.posY + (double)entity.getEyeHeight();
double filled = 1.0f; //If it's not a liquid assume it's a solid block
if (block instanceof IFluidBlock)
{
filled = ((IFluidBlock)block).getFilledPercentage(entity.worldObj, pos);
}
else if (block instanceof BlockLiquid)
{
filled = BlockLiquid.getLiquidHeightPercent(block.getMetaFromState(state));
}
if (filled < 0)
{
filled *= -1;
//filled -= 0.11111111F; //Why this is needed.. not sure...
return eyes > (double)(pos.getY() + 1 + (1 - filled));
}
else
{
return eyes < (double)(pos.getY() + 1 + filled);
}
}
public static boolean onPlayerAttackTarget(EntityPlayer player, Entity target)
{
if (MinecraftForge.EVENT_BUS.post(new AttackEntityEvent(player, target))) return false;
ItemStack stack = player.getCurrentEquippedItem();
if (stack != null && stack.getItem().onLeftClickEntity(stack, player, target)) return false;
return true;
}
}
@@ -1,8 +1,8 @@
package net.minecraftforge.common;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.Item;
@@ -34,25 +34,25 @@ import com.google.common.collect.ImmutableList;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import cpw.mods.fml.client.FMLFileResourcePack;
import cpw.mods.fml.client.FMLFolderResourcePack;
import cpw.mods.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
import cpw.mods.fml.common.DummyModContainer;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.LoadController;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.WorldAccessContainer;
import cpw.mods.fml.common.event.FMLConstructionEvent;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLModIdMappingEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.client.FMLFileResourcePack;
import net.minecraftforge.fml.client.FMLFolderResourcePack;
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
import net.minecraftforge.fml.common.DummyModContainer;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.LoadController;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModMetadata;
import net.minecraftforge.fml.common.WorldAccessContainer;
import net.minecraftforge.fml.common.event.FMLConstructionEvent;
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
import net.minecraftforge.fml.common.event.FMLModIdMappingEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
public class ForgeModContainer extends DummyModContainer implements WorldAccessContainer
{
@@ -190,9 +190,9 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
FMLLog.warning("Enabling removal of erroring Tile Entities - USE AT YOUR OWN RISK");
}
//prop = config.get(Configuration.CATEGORY_GENERAL, "disableStitchedFileSaving", true);
//prop.comment = "Set this to just disable the texture stitcher from writing the 'debug.stitched_{name}.png file to disc. Just a small performance tweak. Default: true";
//disableStitchedFileSaving = prop.getBoolean(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";
disableStitchedFileSaving = prop.getBoolean(true);
prop = config.get(Configuration.CATEGORY_GENERAL, "fullBoundingBoxLadders", false);
prop.comment = "Set this to true to check the entire entity's collision bounding box for ladders instead of just the block they are in. Causes noticable differences in mechanics so default is vanilla behavior. Default: false";
@@ -253,7 +253,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
}
}
}
@SubscribeEvent
public void playerLogin(PlayerEvent.PlayerLoggedInEvent event)
{
@@ -321,7 +321,6 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
@Subscribe
public void mappingChanged(FMLModIdMappingEvent evt)
{
Blocks.fire.rebuildFireInfo();
OreDictionary.rebakeMap();
}
@@ -13,17 +13,17 @@ import java.util.Map;
import com.google.common.io.ByteStreams;
import com.google.gson.Gson;
import cpw.mods.fml.common.versioning.ArtifactVersion;
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
import net.minecraftforge.fml.common.versioning.ArtifactVersion;
import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion;
public class ForgeVersion
{
//This number is incremented every time we remove deprecated code/major API changes, never reset
public static final int majorVersion = 10;
public static final int majorVersion = 11;
//This number is incremented every minecraft release, never reset
public static final int minorVersion = 13;
public static final int minorVersion = 14;
//This number is incremented every time a interface changes or new major feature is added, and reset every Minecraft version
public static final int revisionVersion = 2;
public static final int revisionVersion = 0;
//This number is incremented every time Jenkins builds Forge, and never reset. Should always be 0 in the repo code.
public static final int buildVersion = 0;
@@ -1,11 +1,12 @@
package net.minecraftforge.common;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
public interface IPlantable
{
public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z);
public Block getPlant(IBlockAccess world, int x, int y, int z);
public int getPlantMetadata(IBlockAccess world, int x, int y, int z);
public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos);
public IBlockState getPlant(IBlockAccess world, BlockPos pos);
}
@@ -1,8 +1,9 @@
package net.minecraftforge.common;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
/**
@@ -21,12 +22,10 @@ public interface IShearable
*
* @param item The itemstack that is being used, Possible to be null
* @param world The current world
* @param x The X Position
* @param y The Y Position
* @param z The Z Position
* @param pos Block's position in world.
* @return If this is shearable, and onSheared should be called.
*/
public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z);
public boolean isShearable(ItemStack item, IBlockAccess world, BlockPos pos);
/**
* Performs the shear function on this object.
@@ -42,11 +41,9 @@ public interface IShearable
*
* @param item The itemstack that is being used, Possible to be null
* @param world The current world
* @param x The X Position
* @param y The Y Position
* @param z The Z Position
* @param pos If this is a block, the block's position in world.
* @param fortune The fortune level of the shears being used
* @return A ArrayList containing all items from this shearing. Possible to be null.
*/
public ArrayList<ItemStack> onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune);
public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune);
}
@@ -64,7 +64,7 @@ public interface ISpecialArmor
* @param slot The armor slot the item is in.
*/
public abstract void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot);
public static class ArmorProperties implements Comparable<ArmorProperties>
{
public int Priority = 0;
@@ -90,7 +90,7 @@ public interface ISpecialArmor
* @param damage The total damage being done
* @return The left over damage that has not been absorbed by the armor
*/
public static float ApplyArmor(EntityLivingBase entity, ItemStack[] inventory, DamageSource source, double damage)
public static float applyArmor(EntityLivingBase entity, ItemStack[] inventory, DamageSource source, double damage)
{
if (DEBUG)
{
@@ -1,8 +1,8 @@
package net.minecraftforge.common;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.eventhandler.EventBus;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.eventhandler.EventBus;
import net.minecraft.crash.CrashReport;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeHooks.SeedEntry;
@@ -23,7 +23,7 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
import cpw.mods.fml.relauncher.FMLInjectionData;
import net.minecraftforge.fml.relauncher.FMLInjectionData;
/**
* Caches player's last known usernames
@@ -23,8 +23,6 @@ public class WorldSpecificSaveHandler implements ISaveHandler
{
this.world = world;
this.parent = parent;
dataDir = new File(world.getChunkSaveLocation(), "data");
dataDir.mkdirs();
}
@Override public WorldInfo loadWorldInfo() { return parent.loadWorldInfo(); }
@@ -32,7 +30,7 @@ public class WorldSpecificSaveHandler implements ISaveHandler
@Override public IChunkLoader getChunkLoader(WorldProvider var1) { return parent.getChunkLoader(var1); }
@Override public void saveWorldInfoWithPlayer(WorldInfo var1, NBTTagCompound var2) { parent.saveWorldInfoWithPlayer(var1, var2); }
@Override public void saveWorldInfo(WorldInfo var1){ parent.saveWorldInfo(var1); }
@Override public IPlayerFileData getSaveHandler() { return parent.getSaveHandler(); }
@Override public IPlayerFileData getPlayerNBTManager() { return parent.getPlayerNBTManager(); }
@Override public void flush() { parent.flush(); }
@Override public String getWorldDirectoryName() { return parent.getWorldDirectoryName(); }
@Override public File getWorldDirectory() { return parent.getWorldDirectory(); }
@@ -40,6 +38,11 @@ public class WorldSpecificSaveHandler implements ISaveHandler
@Override
public File getMapFileFromName(String name)
{
if (dataDir == null) //Delayed down here do that world has time to be initalized first.
{
dataDir = new File(world.getChunkSaveLocation(), "data");
dataDir.mkdirs();
}
return new File(dataDir, name + ".dat");
}
@@ -40,13 +40,13 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChu
queuedChunk.loader.loadEntities(queuedChunk.world, queuedChunk.compound.getCompoundTag("Level"), chunk);
MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Load(chunk, queuedChunk.compound)); // Don't call ChunkDataEvent.Load async
chunk.lastSaveTime = queuedChunk.provider.worldObj.getTotalWorldTime();
queuedChunk.provider.loadedChunkHashMap.add(ChunkCoordIntPair.chunkXZ2Int(queuedChunk.x, queuedChunk.z), chunk);
chunk.setLastSaveTime(queuedChunk.provider.worldObj.getTotalWorldTime());
queuedChunk.provider.id2ChunkMap.add(ChunkCoordIntPair.chunkXZ2Int(queuedChunk.x, queuedChunk.z), chunk);
queuedChunk.provider.loadedChunks.add(chunk);
chunk.onChunkLoad();
if (queuedChunk.provider.currentChunkProvider != null) {
queuedChunk.provider.currentChunkProvider.recreateStructures(queuedChunk.x, queuedChunk.z);
if (queuedChunk.provider.serverChunkGenerator != null) {
queuedChunk.provider.serverChunkGenerator.func_180514_a(chunk, queuedChunk.x, queuedChunk.z);
}
chunk.populateChunk(queuedChunk.provider, queuedChunk.provider, queuedChunk.x, queuedChunk.z);
@@ -43,7 +43,7 @@ class QueuedChunk {
result.append(" z: " + z + NEW_LINE);
result.append(" loader: " + loader + NEW_LINE );
result.append(" world: " + world.getWorldInfo().getWorldName() + NEW_LINE);
result.append(" dimension: " + world.provider.dimensionId + NEW_LINE);
result.append(" dimension: " + world.provider.getDimensionId() + NEW_LINE);
result.append(" provider: " + world.provider.getClass().getName() + NEW_LINE);
result.append("}");
@@ -24,7 +24,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import cpw.mods.fml.client.config.GuiConfigEntries.IConfigEntry;
import net.minecraftforge.fml.client.config.GuiConfigEntries.IConfigEntry;
public class ConfigCategory implements Map<String, Property>
{
@@ -11,41 +11,41 @@ import java.util.Iterator;
import java.util.List;
import java.util.regex.Pattern;
import cpw.mods.fml.client.config.ConfigGuiType;
import cpw.mods.fml.client.config.GuiConfigEntries.IConfigEntry;
import cpw.mods.fml.client.config.GuiEditArrayEntries.IArrayEntry;
import cpw.mods.fml.client.config.IConfigElement;
import net.minecraftforge.fml.client.config.ConfigGuiType;
import net.minecraftforge.fml.client.config.GuiConfigEntries.IConfigEntry;
import net.minecraftforge.fml.client.config.GuiEditArrayEntries.IArrayEntry;
import net.minecraftforge.fml.client.config.IConfigElement;
/**
* This class bridges the gap between the FML config GUI classes and the Forge Configuration classes.
*/
public class ConfigElement<T> implements IConfigElement<T>
public class ConfigElement implements IConfigElement
{
private Property prop;
private Property.Type type;
private boolean isProperty;
private ConfigCategory ctgy;
private boolean categoriesFirst = true;
public ConfigElement(ConfigCategory ctgy)
{
this.ctgy = ctgy;
isProperty = false;
}
public ConfigElement(Property prop)
{
this.prop = prop;
this.type = prop.getType();
this.isProperty = true;
}
public ConfigElement<T> listCategoriesFirst(boolean categoriesFirst)
public ConfigElement listCategoriesFirst(boolean categoriesFirst)
{
this.categoriesFirst = categoriesFirst;
return this;
}
@Override
public List<IConfigElement> getChildElements()
{
@@ -55,7 +55,7 @@ public class ConfigElement<T> implements IConfigElement<T>
Iterator<ConfigCategory> ccI = ctgy.getChildren().iterator();
Iterator<Property> pI = ctgy.getOrderedValues().iterator();
int index = 0;
if (categoriesFirst)
while (ccI.hasNext())
{
@@ -63,14 +63,14 @@ public class ConfigElement<T> implements IConfigElement<T>
if (temp.showInGui()) // don't bother adding elements that shouldn't show
elements.add(temp);
}
while (pI.hasNext())
{
ConfigElement<?> temp = getTypedElement(pI.next());
ConfigElement temp = new ConfigElement(pI.next());
if (temp.showInGui())
elements.add(temp);
}
if (!categoriesFirst)
while (ccI.hasNext())
{
@@ -78,39 +78,24 @@ public class ConfigElement<T> implements IConfigElement<T>
if (temp.showInGui())
elements.add(temp);
}
return elements;
}
return null;
}
public static ConfigElement<?> getTypedElement(Property prop)
{
switch (getType(prop))
{
case BOOLEAN:
return new ConfigElement<Boolean>(prop);
case DOUBLE:
return new ConfigElement<Double>(prop);
case INTEGER:
return new ConfigElement<Integer>(prop);
default:
return new ConfigElement<String>(prop);
}
}
@Override
public String getName()
{
return isProperty ? prop.getName() : ctgy.getName();
}
@Override
public boolean isProperty()
{
return isProperty;
}
@Override
public Class<? extends IConfigEntry> getConfigEntryClass()
{
@@ -122,63 +107,63 @@ public class ConfigElement<T> implements IConfigElement<T>
{
return isProperty ? prop.getArrayEntryClass() : null;
}
@Override
public String getQualifiedName()
{
return isProperty ? prop.getName() : ctgy.getQualifiedName();
}
@Override
public ConfigGuiType getType()
{
return isProperty ? getType(this.prop) : ConfigGuiType.CONFIG_CATEGORY;
}
public static ConfigGuiType getType(Property prop)
{
return prop.getType() == Property.Type.BOOLEAN ? ConfigGuiType.BOOLEAN : prop.getType() == Property.Type.DOUBLE ? ConfigGuiType.DOUBLE :
prop.getType() == Property.Type.INTEGER ? ConfigGuiType.INTEGER : prop.getType() == Property.Type.COLOR ? ConfigGuiType.COLOR :
return prop.getType() == Property.Type.BOOLEAN ? ConfigGuiType.BOOLEAN : prop.getType() == Property.Type.DOUBLE ? ConfigGuiType.DOUBLE :
prop.getType() == Property.Type.INTEGER ? ConfigGuiType.INTEGER : prop.getType() == Property.Type.COLOR ? ConfigGuiType.COLOR :
prop.getType() == Property.Type.MOD_ID ? ConfigGuiType.MOD_ID : ConfigGuiType.STRING;
}
@Override
public boolean isList()
{
return isProperty && prop.isList();
}
@Override
public boolean isListLengthFixed()
{
return isProperty && prop.isListLengthFixed();
}
@Override
public int getMaxListLength()
{
return isProperty ? prop.getMaxListLength() : -1;
}
@Override
public String getComment()
{
return isProperty ? prop.comment : ctgy.getComment();
}
@Override
public boolean isDefault()
{
return !isProperty || prop.isDefault();
}
@Override
public void setToDefault()
{
if (isProperty)
prop.setToDefault();
}
@Override
public boolean requiresWorldRestart()
{
@@ -196,25 +181,25 @@ public class ConfigElement<T> implements IConfigElement<T>
{
return isProperty ? prop.requiresMcRestart() : ctgy.requiresMcRestart();
}
@Override
public String[] getValidValues()
{
return isProperty ? prop.getValidValues() : null;
}
@Override
public String getLanguageKey()
{
return isProperty ? prop.getLanguageKey() : ctgy.getLanguagekey();
}
@Override
public Object getDefault()
{
return isProperty ? (T) prop.getDefault() : null;
return isProperty ? prop.getDefault() : null;
}
@Override
public Object[] getDefaults()
{
@@ -247,7 +232,7 @@ public class ConfigElement<T> implements IConfigElement<T>
}
return null;
}
@Override
public Pattern getValidationPattern()
{
@@ -257,7 +242,7 @@ public class ConfigElement<T> implements IConfigElement<T>
@Override
public Object get()
{
return isProperty ? (T) prop.getString() : null;
return isProperty ? prop.getString() : null;
}
@Override
@@ -294,7 +279,7 @@ public class ConfigElement<T> implements IConfigElement<T>
}
@Override
public void set(T value)
public void set(Object value)
{
if (isProperty)
{
@@ -310,7 +295,7 @@ public class ConfigElement<T> implements IConfigElement<T>
}
@Override
public void set(T[] aVal)
public void set(Object[] aVal)
{
if (isProperty)
{
@@ -346,14 +331,14 @@ public class ConfigElement<T> implements IConfigElement<T>
}
@Override
public T getMinValue()
public Object getMinValue()
{
return isProperty ? (T) prop.getMinValue() : null;
return isProperty ? prop.getMinValue() : null;
}
@Override
public T getMaxValue()
public Object getMaxValue()
{
return isProperty ? (T) prop.getMaxValue() : null;
return isProperty ? prop.getMaxValue() : null;
}
}
@@ -36,10 +36,10 @@ import java.util.regex.Pattern;
import com.google.common.base.CharMatcher;
import com.google.common.collect.ImmutableSet;
import cpw.mods.fml.client.config.GuiConfigEntries.IConfigEntry;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.FMLInjectionData;
import net.minecraftforge.fml.client.config.GuiConfigEntries.IConfigEntry;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.relauncher.FMLInjectionData;
/**
* This class offers advanced configurations capabilities, allowing to provide
@@ -9,8 +9,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.regex.Pattern;
import cpw.mods.fml.client.config.GuiConfigEntries.IConfigEntry;
import cpw.mods.fml.client.config.GuiEditArrayEntries.IArrayEntry;
import net.minecraftforge.fml.client.config.GuiConfigEntries.IConfigEntry;
import net.minecraftforge.fml.client.config.GuiEditArrayEntries.IArrayEntry;
public class Property
{
@@ -5,7 +5,7 @@ import io.netty.channel.SimpleChannelInboundHandler;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.network.ForgeMessage.DimensionRegisterMessage;
import org.apache.logging.log4j.Level;
import cpw.mods.fml.common.FMLLog;
import net.minecraftforge.fml.common.FMLLog;
public class DimensionMessageHandler extends SimpleChannelInboundHandler<ForgeMessage.DimensionRegisterMessage>{
@Override
@@ -4,7 +4,7 @@ import net.minecraftforge.fluids.FluidRegistry;
import org.apache.logging.log4j.Level;
import cpw.mods.fml.common.FMLLog;
import net.minecraftforge.fml.common.FMLLog;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
@@ -7,7 +7,7 @@ import net.minecraftforge.fluids.FluidRegistry;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import cpw.mods.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
public abstract class ForgeMessage {
@@ -2,12 +2,12 @@ package net.minecraftforge.common.network;
import java.util.EnumMap;
import net.minecraftforge.common.ForgeModContainer;
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
import cpw.mods.fml.common.network.FMLOutboundHandler;
import cpw.mods.fml.common.network.FMLOutboundHandler.OutboundTarget;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.common.network.FMLEmbeddedChannel;
import net.minecraftforge.fml.common.network.FMLOutboundHandler;
import net.minecraftforge.fml.common.network.FMLOutboundHandler.OutboundTarget;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ForgeNetworkHandler
{
@@ -2,7 +2,7 @@ package net.minecraftforge.common.network;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec;
import net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec;
public class ForgeRuntimeCodec extends FMLIndexedMessageToMessageCodec<ForgeMessage> {
public ForgeRuntimeCodec()
@@ -1,6 +1,6 @@
package net.minecraftforge.common.network;
import cpw.mods.fml.common.network.NetworkHandshakeEstablished;
import net.minecraftforge.fml.common.network.NetworkHandshakeEstablished;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
@@ -12,7 +12,7 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import cpw.mods.fml.common.FMLLog;
import net.minecraftforge.fml.common.FMLLog;
/**
@@ -4,12 +4,14 @@ package net.minecraftforge.common.util;
import java.io.Serializable;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
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,29 +25,25 @@ public class BlockSnapshot implements Serializable
{
private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockSnapshot", "false"));
public final int x;
public final int y;
public final int z;
public final BlockPos pos;
public final int dimId;
public transient Block replacedBlock;
public final int meta;
public transient IBlockState replacedBlock;
public int flag;
private final NBTTagCompound nbt;
public transient World world;
public final UniqueIdentifier blockIdentifier;
public final int meta;
public BlockSnapshot(World world, int x, int y, int z, Block block, int meta)
public BlockSnapshot(World world, BlockPos pos, IBlockState state)
{
this.world = world;
this.dimId = world.provider.dimensionId;
this.x = x;
this.y = y;
this.z = z;
this.replacedBlock = block;
this.blockIdentifier = GameRegistry.findUniqueIdentifierFor(block);
this.meta = meta;
this.dimId = world.provider.getDimensionId();
this.pos = pos;
this.replacedBlock = state;
this.blockIdentifier = GameRegistry.findUniqueIdentifierFor(state.getBlock());
this.meta = state.getBlock().getMetaFromState(state);
this.flag = 3;
TileEntity te = world.getTileEntity(x, y, z);
TileEntity te = world.getTileEntity(pos);
if (te != null)
{
nbt = new NBTTagCompound();
@@ -54,57 +52,53 @@ public class BlockSnapshot implements Serializable
else nbt = null;
if (DEBUG)
{
System.out.printf("Created BlockSnapshot - [World: %s ][Location: %d,%d,%d ][Block: %s ][Meta: %d ]", world.getWorldInfo().getWorldName(), x, y, z, block, 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(), blockIdentifier, meta);
}
}
public BlockSnapshot(World world, int x, int y, int z, Block block, int meta, NBTTagCompound nbt)
public BlockSnapshot(World world, BlockPos pos, IBlockState state, NBTTagCompound nbt)
{
this.world = world;
this.dimId = world.provider.dimensionId;
this.x = x;
this.y = y;
this.z = z;
this.replacedBlock = block;
this.blockIdentifier = GameRegistry.findUniqueIdentifierFor(block);
this.meta = meta;
this.dimId = world.provider.getDimensionId();
this.pos = pos;
this.replacedBlock = state;
this.blockIdentifier = GameRegistry.findUniqueIdentifierFor(state.getBlock());
this.meta = state.getBlock().getMetaFromState(state);
this.flag = 3;
this.nbt = nbt;
if (DEBUG)
{
System.out.printf("Created BlockSnapshot - [World: %s ][Location: %d,%d,%d ][Block: %s ][Meta: %d ]", world.getWorldInfo().getWorldName(), x, y, z, block, 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(), blockIdentifier, meta);
}
}
public BlockSnapshot(World world, int x, int y, int z, Block block, int meta, int flag)
public BlockSnapshot(World world, BlockPos pos, IBlockState state, int flag)
{
this(world, x, y, z, block, meta);
this(world, pos, state);
this.flag = flag;
}
/**
* Raw constructor designed for serialization usages.
*/
public BlockSnapshot(int dimension, int x, int y, int z, String modid, String blockName, int meta, int flag, NBTTagCompound nbt)
public BlockSnapshot(int dimension, BlockPos pos, String modid, String blockName, int meta, int flag, NBTTagCompound nbt)
{
this.dimId = dimension;
this.x = x;
this.y = y;
this.z = z;
this.meta = meta;
this.pos = pos;
this.flag = flag;
this.blockIdentifier = new UniqueIdentifier(modid + ":" + blockName);
this.meta = meta;
this.nbt = nbt;
}
public static BlockSnapshot getBlockSnapshot(World world, int x, int y, int z)
public static BlockSnapshot getBlockSnapshot(World world, BlockPos pos)
{
return new BlockSnapshot(world, x, y, z, world.getBlock(x, y, z), world.getBlockMetadata(x, y,z));
return new BlockSnapshot(world, pos, world.getBlockState(pos));
}
public static BlockSnapshot getBlockSnapshot(World world, int x, int y, int z, int flag)
public static BlockSnapshot getBlockSnapshot(World world, BlockPos pos, int flag)
{
return new BlockSnapshot(world, x, y, z, world.getBlock(x, y, z), world.getBlockMetadata(x, y,z), flag);
return new BlockSnapshot(world, pos, world.getBlockState(pos), flag);
}
public static BlockSnapshot readFromNBT(NBTTagCompound tag)
@@ -113,9 +107,7 @@ public class BlockSnapshot implements Serializable
return new BlockSnapshot(
tag.getInteger("dimension"),
tag.getInteger("posX"),
tag.getInteger("posY"),
tag.getInteger("posZ"),
new BlockPos(tag.getInteger("posX"), tag.getInteger("posY"), tag.getInteger("posZ")),
tag.getString("blockMod"),
tag.getString("blockName"),
tag.getInteger("metadata"),
@@ -123,25 +115,25 @@ public class BlockSnapshot implements Serializable
nbt);
}
public Block getCurrentBlock()
public IBlockState getCurrentBlock()
{
return world.getBlock(x, y, z);
return world.getBlockState(pos);
}
public World getWorld()
public World getWorld()
{
if (this.world == null)
if (this.world == null)
{
this.world = DimensionManager.getWorld(dimId);
}
return this.world;
}
public Block getReplacedBlock()
public IBlockState getReplacedBlock()
{
if (this.replacedBlock == null)
if (this.replacedBlock == null)
{
this.replacedBlock = GameRegistry.findBlock(this.blockIdentifier.modId, this.blockIdentifier.name);
this.replacedBlock = GameRegistry.findBlock(this.blockIdentifier.modId, this.blockIdentifier.name).getStateFromMeta(meta);
}
return this.replacedBlock;
}
@@ -153,69 +145,38 @@ public class BlockSnapshot implements Serializable
else return null;
}
public boolean restore()
public boolean restore()
{
return restore(false);
}
public boolean restore(boolean force)
public boolean restore(boolean force)
{
return restore(force, true);
}
public boolean restore(boolean force, boolean applyPhysics)
public boolean restore(boolean force, boolean applyPhysics)
{
if (getCurrentBlock() != getReplacedBlock() || world.getBlockMetadata(x & 15, y, z & 15) != meta)
IBlockState current = getCurrentBlock();
IBlockState replaced = getReplacedBlock();
if (current.getBlock() != replaced.getBlock() || current.getBlock().getMetaFromState(current) != replaced.getBlock().getMetaFromState(replaced))
{
if (force)
{
world.setBlock(x, y, z, getReplacedBlock(), meta, applyPhysics ? 3 : 2);
world.setBlockState(pos, replaced, applyPhysics ? 3 : 2);
}
else
{
return false;
}
}
world.setBlockMetadataWithNotify(x, y, z, meta, applyPhysics ? 3 : 2);
world.markBlockForUpdate(x, y, z);
TileEntity te = null;
if (nbt != null)
{
te = world.getTileEntity(x, y, z);
if (te != null)
{
te.readFromNBT(nbt);
}
}
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(), x, y, z, meta, getReplacedBlock(), te, force, applyPhysics);
}
return true;
}
public boolean restoreToLocation(World world, int x, int y, int z, boolean force, boolean applyPhysics)
{
if (getCurrentBlock() != getReplacedBlock() || world.getBlockMetadata(x & 15, y, z & 15) != meta)
{
if (force)
{
world.setBlock(x, y, z, getReplacedBlock(), meta, applyPhysics ? 3 : 2);
}
else
{
return false;
}
}
world.setBlockMetadataWithNotify(x, y, z, meta, applyPhysics ? 3 : 2);
world.markBlockForUpdate(x, y, z);
world.setBlockState(pos, replaced, applyPhysics ? 3 : 2);
world.markBlockForUpdate(pos);
TileEntity te = null;
if (nbt != null)
{
te = world.getTileEntity(x, y, z);
te = world.getTileEntity(pos);
if (te != null)
{
te.readFromNBT(nbt);
@@ -224,7 +185,42 @@ public class BlockSnapshot implements Serializable
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(), x, y, z, meta, getReplacedBlock(), 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]", world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ(), replaced.getBlock().getMetaFromState(replaced), replaced.getBlock().delegate.name(), te, force, applyPhysics);
}
return true;
}
public boolean restoreToLocation(World world, BlockPos pos, boolean force, boolean applyPhysics)
{
IBlockState current = getCurrentBlock();
IBlockState replaced = getReplacedBlock();
if (current.getBlock() != replaced.getBlock() || current.getBlock().getMetaFromState(current) != replaced.getBlock().getMetaFromState(replaced))
{
if (force)
{
world.setBlockState(pos, replaced, applyPhysics ? 3 : 2);
}
else
{
return false;
}
}
world.setBlockState(pos, replaced, applyPhysics ? 3 : 2);
world.markBlockForUpdate(pos);
TileEntity te = null;
if (nbt != null)
{
te = world.getTileEntity(pos);
if (te != null)
{
te.readFromNBT(nbt);
}
}
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);
}
return true;
}
@@ -233,9 +229,9 @@ public class BlockSnapshot implements Serializable
{
compound.setString("blockMod", blockIdentifier.modId);
compound.setString("blockName", blockIdentifier.name);
compound.setInteger("posX", x);
compound.setInteger("posY", y);
compound.setInteger("posZ", z);
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);
@@ -249,7 +245,7 @@ public class BlockSnapshot implements Serializable
}
@Override
public boolean equals(Object obj)
public boolean equals(Object obj)
{
if (obj == null)
{
@@ -260,15 +256,7 @@ public class BlockSnapshot implements Serializable
return false;
}
final BlockSnapshot other = (BlockSnapshot) obj;
if (this.x != other.x)
{
return false;
}
if (this.y != other.y)
{
return false;
}
if (this.z != other.z)
if (!this.pos.equals(other.pos))
{
return false;
}
@@ -299,9 +287,9 @@ public class BlockSnapshot implements Serializable
public int hashCode()
{
int hash = 7;
hash = 73 * hash + this.x;
hash = 73 * hash + this.y;
hash = 73 * hash + this.z;
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);
@@ -3,11 +3,10 @@ package net.minecraftforge.common.util;
import java.lang.reflect.*;
import java.util.*;
import cpw.mods.fml.common.FMLLog;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraft.block.BlockPressurePlate.Sensitivity;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.EnumEnchantmentType;
import net.minecraft.entity.Entity.EnumEntitySize;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.item.EntityPainting.EnumArt;
@@ -42,7 +41,6 @@ public class EnumHelper
{EnumCreatureType.class, Class.class, int.class, Material.class, boolean.class, boolean.class},
{Door.class},
{EnumEnchantmentType.class},
{EnumEntitySize.class},
{Sensitivity.class},
{MovingObjectType.class},
{EnumSkyBlock.class, int.class},
@@ -80,10 +78,6 @@ public class EnumHelper
{
return addEnum(EnumEnchantmentType.class, name);
}
public static EnumEntitySize addEntitySize(String name)
{
return addEnum(EnumEntitySize.class, name);
}
public static Sensitivity addSensitivity(String name)
{
return addEnum(Sensitivity.class, name);
@@ -2,19 +2,19 @@ package net.minecraftforge.common.util;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.play.client.C15PacketClientSettings;
import net.minecraft.server.management.ItemInWorldManager;
import net.minecraft.stats.StatBase;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.DamageSource;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
//Preliminary, simple Fake Player class
//Preliminary, simple Fake Player class
public class FakePlayer extends EntityPlayerMP
{
public FakePlayer(WorldServer world, GameProfile name)
@@ -22,19 +22,15 @@ public class FakePlayer extends EntityPlayerMP
super(FMLCommonHandler.instance().getMinecraftServerInstance(), world, name, new ItemInWorldManager(world));
}
@Override public Vec3 getPositionVector(){ return new Vec3(0, 0, 0); }
@Override public boolean canCommandSenderUseCommand(int i, String s){ return false; }
@Override public ChunkCoordinates getPlayerCoordinates()
{
return new ChunkCoordinates(0,0,0);
}
@Override public void addChatComponentMessage(IChatComponent chatmessagecomponent){}
@Override public void addStat(StatBase par1StatBase, int par2){}
@Override public void openGui(Object mod, int modGuiId, World world, int x, int y, int z){}
@Override public boolean isEntityInvulnerable(){ return true; }
@Override public boolean func_180431_b(DamageSource source){ return true; }
@Override public boolean canAttackPlayer(EntityPlayer player){ return false; }
@Override public void onDeath(DamageSource source){ return; }
@Override public void onUpdate(){ return; }
@Override public void travelToDimension(int dim){ return; }
@Override public void func_147100_a(C15PacketClientSettings pkt){ return; }
@Override public void handleClientSettings(C15PacketClientSettings pkt){ return; }
}
@@ -1,71 +0,0 @@
package net.minecraftforge.common.util;
public enum ForgeDirection
{
/** -Y */
DOWN(0, -1, 0),
/** +Y */
UP(0, 1, 0),
/** -Z */
NORTH(0, 0, -1),
/** +Z */
SOUTH(0, 0, 1),
/** -X */
WEST(-1, 0, 0),
/** +X */
EAST(1, 0, 0),
/**
* Used only by getOrientation, for invalid inputs
*/
UNKNOWN(0, 0, 0);
public final int offsetX;
public final int offsetY;
public final int offsetZ;
public final int flag;
public static final ForgeDirection[] VALID_DIRECTIONS = {DOWN, UP, NORTH, SOUTH, WEST, EAST};
public static final int[] OPPOSITES = {1, 0, 3, 2, 5, 4, 6};
// Left hand rule rotation matrix for all possible axes of rotation
public static final int[][] ROTATION_MATRIX = {
{0, 1, 4, 5, 3, 2, 6},
{0, 1, 5, 4, 2, 3, 6},
{5, 4, 2, 3, 0, 1, 6},
{4, 5, 2, 3, 1, 0, 6},
{2, 3, 1, 0, 4, 5, 6},
{3, 2, 0, 1, 4, 5, 6},
{0, 1, 2, 3, 4, 5, 6},
};
private ForgeDirection(int x, int y, int z)
{
offsetX = x;
offsetY = y;
offsetZ = z;
flag = 1 << ordinal();
}
public static ForgeDirection getOrientation(int id)
{
if (id >= 0 && id < VALID_DIRECTIONS.length)
{
return VALID_DIRECTIONS[id];
}
return UNKNOWN;
}
public ForgeDirection getOpposite()
{
return getOrientation(OPPOSITES[ordinal()]);
}
public ForgeDirection getRotation(ForgeDirection axis)
{
return getOrientation(ROTATION_MATRIX[axis.ordinal()][ordinal()]);
}
}
@@ -1,439 +0,0 @@
package net.minecraftforge.common.util;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import net.minecraft.block.Block;
import net.minecraft.block.BlockAnvil;
import net.minecraft.block.BlockBed;
import net.minecraft.block.BlockButton;
import net.minecraft.block.BlockChest;
import net.minecraft.block.BlockCocoa;
import net.minecraft.block.BlockDispenser;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.BlockEndPortalFrame;
import net.minecraft.block.BlockEnderChest;
import net.minecraft.block.BlockFenceGate;
import net.minecraft.block.BlockFurnace;
import net.minecraft.block.BlockHopper;
import net.minecraft.block.BlockHugeMushroom;
import net.minecraft.block.BlockLadder;
import net.minecraft.block.BlockLever;
import net.minecraft.block.BlockLog;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.BlockPistonExtension;
import net.minecraft.block.BlockPumpkin;
import net.minecraft.block.BlockRail;
import net.minecraft.block.BlockRailDetector;
import net.minecraft.block.BlockRailPowered;
import net.minecraft.block.BlockRedstoneComparator;
import net.minecraft.block.BlockRedstoneRepeater;
import net.minecraft.block.BlockSkull;
import net.minecraft.block.BlockStairs;
import net.minecraft.block.BlockTorch;
import net.minecraft.block.BlockTrapDoor;
import net.minecraft.block.BlockTripWireHook;
import net.minecraft.block.BlockVine;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import java.util.HashMap;
import java.util.Map;
import static net.minecraftforge.common.util.ForgeDirection.*;
/**
* This class is a helper function for vanilla blocks, and should not be called by Modders.
* Refer to block.rotateBlock and block.getValidRotations instead.
*
*/
public class RotationHelper {
/**
* Some blocks have the same rotation.
* The first of these blocks (sorted by itemID) should be listed as a type.
* Some of the types aren't actual blocks (helper types).
*/
private static enum BlockType {
LOG,
DISPENSER,
BED,
RAIL,
RAIL_POWERED,
RAIL_ASCENDING,
RAIL_CORNER,
TORCH,
STAIR,
CHEST,
SIGNPOST,
DOOR,
LEVER,
BUTTON,
REDSTONE_REPEATER,
TRAPDOOR,
MUSHROOM_CAP,
MUSHROOM_CAP_CORNER,
MUSHROOM_CAP_SIDE,
VINE,
SKULL,
ANVIL
}
private static final ForgeDirection[] UP_DOWN_AXES = new ForgeDirection[] { UP, DOWN };
private static final Map<BlockType, BiMap<Integer, ForgeDirection>> MAPPINGS = new HashMap<BlockType, BiMap<Integer, ForgeDirection>>();
public static ForgeDirection[] getValidVanillaBlockRotations(Block block)
{
return (block instanceof BlockBed ||
block instanceof BlockPumpkin ||
block instanceof BlockFenceGate ||
block instanceof BlockEndPortalFrame ||
block instanceof BlockTripWireHook ||
block instanceof BlockCocoa ||
block instanceof BlockRailPowered ||
block instanceof BlockRailDetector ||
block instanceof BlockStairs ||
block instanceof BlockChest ||
block instanceof BlockEnderChest ||
block instanceof BlockFurnace ||
block instanceof BlockLadder ||
block == Blocks.wall_sign ||
block == Blocks.standing_sign ||
block instanceof BlockDoor ||
block instanceof BlockRail ||
block instanceof BlockButton ||
block instanceof BlockRedstoneRepeater ||
block instanceof BlockRedstoneComparator ||
block instanceof BlockTrapDoor ||
block instanceof BlockHugeMushroom ||
block instanceof BlockVine ||
block instanceof BlockSkull ||
block instanceof BlockAnvil) ? UP_DOWN_AXES : VALID_DIRECTIONS;
}
public static boolean rotateVanillaBlock(Block block, World worldObj, int x, int y, int z, ForgeDirection axis)
{
if (worldObj.isRemote)
{
return false;
}
if (axis == UP || axis == DOWN)
{
if (block instanceof BlockBed || block instanceof BlockPumpkin || block instanceof BlockFenceGate || block instanceof BlockEndPortalFrame || block instanceof BlockTripWireHook || block instanceof BlockCocoa)
{
return rotateBlock(worldObj, x, y, z, axis, 0x3, BlockType.BED);
}
if (block instanceof BlockRail)
{
return rotateBlock(worldObj, x, y, z, axis, 0xF, BlockType.RAIL);
}
if (block instanceof BlockRailPowered || block instanceof BlockRailDetector)
{
return rotateBlock(worldObj, x, y, z, axis, 0x7, BlockType.RAIL_POWERED);
}
if (block instanceof BlockStairs)
{
return rotateBlock(worldObj, x, y, z, axis, 0x3, BlockType.STAIR);
}
if (block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockFurnace || block instanceof BlockLadder || block == Blocks.wall_sign)
{
return rotateBlock(worldObj, x, y, z, axis, 0x7, BlockType.CHEST);
}
if (block == Blocks.standing_sign)
{
return rotateBlock(worldObj, x, y, z, axis, 0xF, BlockType.SIGNPOST);
}
if (block instanceof BlockDoor)
{
return rotateBlock(worldObj, x, y, z, axis, 0x3, BlockType.DOOR);
}
if (block instanceof BlockButton)
{
return rotateBlock(worldObj, x, y, z, axis, 0x7, BlockType.BUTTON);
}
if (block instanceof BlockRedstoneRepeater || block instanceof BlockRedstoneComparator)
{
return rotateBlock(worldObj, x, y, z, axis, 0x3, BlockType.REDSTONE_REPEATER);
}
if (block instanceof BlockTrapDoor)
{
return rotateBlock(worldObj, x, y, z, axis, 0x3, BlockType.TRAPDOOR);
}
if (block instanceof BlockHugeMushroom)
{
return rotateBlock(worldObj, x, y, z, axis, 0xF, BlockType.MUSHROOM_CAP);
}
if (block instanceof BlockVine)
{
return rotateBlock(worldObj, x, y, z, axis, 0xF, BlockType.VINE);
}
if (block instanceof BlockSkull)
{
return rotateBlock(worldObj, x, y, z, axis, 0x7, BlockType.SKULL);
}
if (block instanceof BlockAnvil)
{
return rotateBlock(worldObj, x, y, z, axis, 0x1, BlockType.ANVIL);
}
}
if (block instanceof BlockLog)
{
return rotateBlock(worldObj, x, y, z, axis, 0xC, BlockType.LOG);
}
if (block instanceof BlockDispenser || block instanceof BlockPistonBase || block instanceof BlockPistonExtension || block instanceof BlockHopper)
{
return rotateBlock(worldObj, x, y, z, axis, 0x7, BlockType.DISPENSER);
}
if (block instanceof BlockTorch)
{
return rotateBlock(worldObj, x, y, z, axis, 0xF, BlockType.TORCH);
}
if (block instanceof BlockLever)
{
return rotateBlock(worldObj, x, y, z, axis, 0x7, BlockType.LEVER);
}
return false;
}
private static boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis, int mask, BlockType blockType)
{
int rotMeta = worldObj.getBlockMetadata(x, y, z);
if (blockType == BlockType.DOOR && (rotMeta & 0x8) == 0x8)
{
return false;
}
int masked = rotMeta & ~mask;
int meta = rotateMetadata(axis, blockType, rotMeta & mask);
if (meta == -1)
{
return false;
}
worldObj.setBlockMetadataWithNotify(x, y, z, meta & mask | masked, 3);
return true;
}
private static int rotateMetadata(ForgeDirection axis, BlockType blockType, int meta)
{
if (blockType == BlockType.RAIL || blockType == BlockType.RAIL_POWERED)
{
if (meta == 0x0 || meta == 0x1)
{
return ~meta & 0x1;
}
if (meta >= 0x2 && meta <= 0x5)
{
blockType = BlockType.RAIL_ASCENDING;
}
if (meta >= 0x6 && meta <= 0x9 && blockType == BlockType.RAIL)
{
blockType = BlockType.RAIL_CORNER;
}
}
if (blockType == BlockType.SIGNPOST)
{
return (axis == UP) ? (meta + 0x4) % 0x10 : (meta + 0xC) % 0x10;
}
if (blockType == BlockType.LEVER && (axis == UP || axis == DOWN))
{
switch (meta)
{
case 0x5:
return 0x6;
case 0x6:
return 0x5;
case 0x7:
return 0x0;
case 0x0:
return 0x7;
}
}
if (blockType == BlockType.MUSHROOM_CAP)
{
if (meta % 0x2 == 0)
{
blockType = BlockType.MUSHROOM_CAP_SIDE;
}
else
{
blockType = BlockType.MUSHROOM_CAP_CORNER;
}
}
if (blockType == BlockType.VINE)
{
return ((meta << 1) | ((meta & 0x8) >> 3));
}
ForgeDirection orientation = metadataToDirection(blockType, meta);
ForgeDirection rotated = orientation.getRotation(axis);
return directionToMetadata(blockType, rotated);
}
private static ForgeDirection metadataToDirection(BlockType blockType, int meta)
{
if (blockType == BlockType.LEVER)
{
if (meta == 0x6)
{
meta = 0x5;
}
else if (meta == 0x0)
{
meta = 0x7;
}
}
if (MAPPINGS.containsKey(blockType))
{
BiMap<Integer, ForgeDirection> biMap = MAPPINGS.get(blockType);
if (biMap.containsKey(meta))
{
return biMap.get(meta);
}
}
if (blockType == BlockType.TORCH)
{
return ForgeDirection.getOrientation(6 - meta);
}
if (blockType == BlockType.STAIR)
{
return ForgeDirection.getOrientation(5 - meta);
}
if (blockType == BlockType.CHEST || blockType == BlockType.DISPENSER || blockType == BlockType.SKULL)
{
return ForgeDirection.getOrientation(meta);
}
if (blockType == BlockType.BUTTON)
{
return ForgeDirection.getOrientation(6 - meta);
}
if (blockType == BlockType.TRAPDOOR)
{
return ForgeDirection.getOrientation(meta + 2).getOpposite();
}
return ForgeDirection.UNKNOWN;
}
private static int directionToMetadata(BlockType blockType, ForgeDirection direction)
{
if ((blockType == BlockType.LOG || blockType == BlockType.ANVIL) && (direction.offsetX + direction.offsetY + direction.offsetZ) < 0)
{
direction = direction.getOpposite();
}
if (MAPPINGS.containsKey(blockType))
{
BiMap<ForgeDirection, Integer> biMap = MAPPINGS.get(blockType).inverse();
if (biMap.containsKey(direction))
{
return biMap.get(direction);
}
}
if (blockType == BlockType.TORCH)
{
if (direction.ordinal() >= 1)
{
return 6 - direction.ordinal();
}
}
if (blockType == BlockType.STAIR)
{
return 5 - direction.ordinal();
}
if (blockType == BlockType.CHEST || blockType == BlockType.DISPENSER || blockType == BlockType.SKULL)
{
return direction.ordinal();
}
if (blockType == BlockType.BUTTON)
{
if (direction.ordinal() >= 2)
{
return 6 - direction.ordinal();
}
}
if (blockType == BlockType.TRAPDOOR)
{
return direction.getOpposite().ordinal() - 2;
}
return -1;
}
static
{
BiMap<Integer, ForgeDirection> biMap;
biMap = HashBiMap.create(3);
biMap.put(0x0, UP);
biMap.put(0x4, EAST);
biMap.put(0x8, SOUTH);
MAPPINGS.put(BlockType.LOG, biMap);
biMap = HashBiMap.create(4);
biMap.put(0x0, SOUTH);
biMap.put(0x1, WEST);
biMap.put(0x2, NORTH);
biMap.put(0x3, EAST);
MAPPINGS.put(BlockType.BED, biMap);
biMap = HashBiMap.create(4);
biMap.put(0x2, EAST);
biMap.put(0x3, WEST);
biMap.put(0x4, NORTH);
biMap.put(0x5, SOUTH);
MAPPINGS.put(BlockType.RAIL_ASCENDING, biMap);
biMap = HashBiMap.create(4);
biMap.put(0x6, WEST);
biMap.put(0x7, NORTH);
biMap.put(0x8, EAST);
biMap.put(0x9, SOUTH);
MAPPINGS.put(BlockType.RAIL_CORNER, biMap);
biMap = HashBiMap.create(6);
biMap.put(0x1, EAST);
biMap.put(0x2, WEST);
biMap.put(0x3, SOUTH);
biMap.put(0x4, NORTH);
biMap.put(0x5, UP);
biMap.put(0x7, DOWN);
MAPPINGS.put(BlockType.LEVER, biMap);
biMap = HashBiMap.create(4);
biMap.put(0x0, WEST);
biMap.put(0x1, NORTH);
biMap.put(0x2, EAST);
biMap.put(0x3, SOUTH);
MAPPINGS.put(BlockType.DOOR, biMap);
biMap = HashBiMap.create(4);
biMap.put(0x0, NORTH);
biMap.put(0x1, EAST);
biMap.put(0x2, SOUTH);
biMap.put(0x3, WEST);
MAPPINGS.put(BlockType.REDSTONE_REPEATER, biMap);
biMap = HashBiMap.create(4);
biMap.put(0x1, EAST);
biMap.put(0x3, SOUTH);
biMap.put(0x7, NORTH);
biMap.put(0x9, WEST);
MAPPINGS.put(BlockType.MUSHROOM_CAP_CORNER, biMap);
biMap = HashBiMap.create(4);
biMap.put(0x2, NORTH);
biMap.put(0x4, WEST);
biMap.put(0x6, EAST);
biMap.put(0x8, SOUTH);
MAPPINGS.put(BlockType.MUSHROOM_CAP_SIDE, biMap);
biMap = HashBiMap.create(2);
biMap.put(0x0, SOUTH);
biMap.put(0x1, EAST);
MAPPINGS.put(BlockType.ANVIL, biMap);
}
}