Java 类net.minecraft.util.RegistrySimple 实例源码

项目:ExtraUtilities    文件:DispenserStuff.java   
public static void registerItems() {
    if (!((RegistrySimple)BlockDispenser.dispenseBehaviorRegistry).containsKey((Object)Items.glass_bottle)) {
        BlockDispenser.dispenseBehaviorRegistry.putObject((Object)Items.glass_bottle, (Object)new BehaviorDefaultDispenseItem() {
            private final BehaviorDefaultDispenseItem field_150840_b = new BehaviorDefaultDispenseItem();

            public ItemStack dispenseStack(final IBlockSource par1IBlockSource, final ItemStack par2ItemStack) {
                final EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata());
                final World world = par1IBlockSource.getWorld();
                final int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX();
                final int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY();
                final int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ();
                final Material material = world.getBlock(i, j, k).getMaterial();
                final int l = world.getBlockMetadata(i, j, k);
                if (Material.water.equals(material) && l == 0) {
                    final Item item = (Item)Items.potionitem;
                    if (--par2ItemStack.stackSize == 0) {
                        par2ItemStack.func_150996_a(item);
                        par2ItemStack.stackSize = 1;
                        par2ItemStack.setTagCompound((NBTTagCompound)null);
                    }
                    else if (((TileEntityDispenser)par1IBlockSource.getBlockTileEntity()).func_146019_a(new ItemStack(item)) < 0) {
                        this.field_150840_b.dispense(par1IBlockSource, new ItemStack(item));
                    }
                    return par2ItemStack;
                }
                return super.dispenseStack(par1IBlockSource, par2ItemStack);
            }
        });
    }
}
项目:N-API    文件:BlockRegistry.java   
/**
 * Replaces a block with another block. May not work.
 * @param nonNumericId The string id of the block to remove.
 * @param newBlock The new Block to put in it's place.
 */
@DocumentationAnnotations.Experimental(firstAppearance = "1.0")
public static final void replaceBlock(String nonNumericId, Block newBlock)
{
    Map<String, Block> blocksMap = ReflectionManipulateValues.getValue(RegistrySimple.class, Block.blockRegistry, "registryObjects");
    blocksMap.remove(nonNumericId);
    blocksMap.put(nonNumericId, newBlock);

    ReflectionManipulateValues.setValue(RegistrySimple.class, Block.blockRegistry, "registryObjects", blocksMap);
}
项目:ExtraUtilities    文件:AdvancedNodeUpgrades.java   
public boolean matchItem(final Item item) {
    return ((RegistrySimple)BlockDispenser.dispenseBehaviorRegistry).containsKey((Object)item);
}