Java Code Examples for net.minecraft.block.Block#getRegistryName()

The following examples show how to use net.minecraft.block.Block#getRegistryName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenderHandler.java    From EmergingTechnology with MIT License 6 votes vote down vote up
public static void registerMeshesAndStatesForBlock(Block block) {

        ModelResourceLocation resourceLocation = new ModelResourceLocation(
                block.getRegistryName(), "fluid");

        ItemMeshDefinition meshDefinition = new ItemMeshDefinition() {
            @Override
            public ModelResourceLocation getModelLocation(ItemStack stack) {
                return resourceLocation;
            }
        };

        StateMapperBase stateMapper = new StateMapperBase() {
            @Override
            public ModelResourceLocation getModelResourceLocation(IBlockState state) {
                return resourceLocation;
            }
        };

        ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(block), meshDefinition);
        ModelLoader.setCustomStateMapper(block, stateMapper);

    }
 
Example 2
Source File: EventHandler.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
private static boolean applyModifiers(BlockEvent.CreateFluidSourceEvent event)
{
    Block block = event.getState().getBlock();

    for (FluidModifier modifier : FluidModifier.getModifiers())
    {
        if (block.getRegistryName() != null && block.getRegistryName().equals(modifier.block))
        {
            if (modifier.canCreateSource != null)
            {
                event.setResult(modifier.canCreateSource ? Event.Result.ALLOW : Event.Result.DENY);
                return true;
            }
        }
    }

    return false;
}
 
Example 3
Source File: BlockCompound.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
public BlockCompound(String modid, Block block, ItemBlock item) {
    this.modid = modid;
    this.block = block;
    this.item = item;
    registryName = block.getRegistryName();
}
 
Example 4
Source File: ModelBakery.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void registerBlockKeyGenerator(Block block, IBlockStateKeyGenerator generator) {
    if (blockKeyGeneratorMap.containsKey(block)) {
        throw new IllegalArgumentException("Unable to register IBlockStateKeyGenerator as one is already registered for block:" + block.getRegistryName());
    }
    blockKeyGeneratorMap.put(block, generator);
}
 
Example 5
Source File: PlaceCommandsImplementation.java    From malmo with MIT License 4 votes vote down vote up
@Override
protected boolean onExecute(String verb, String parameter, MissionInit missionInit) {
    EntityPlayerSP player = Minecraft.getMinecraft().player;
    if (player == null)
        return false;

    if (!verb.equalsIgnoreCase("place"))
        return false;

    Item item = Item.getByNameOrId(parameter);
    Block block = Block.getBlockFromItem(item);
    if (item == null || item.getRegistryName() == null || block.getRegistryName() == null)
        return false;

    InventoryPlayer inv = player.inventory;
    boolean blockInInventory = false;
    ItemStack stackInInventory = null;
    int stackIndex = -1;
    for (int i = 0; !blockInInventory && i < inv.getSizeInventory(); i++) {
        Item stack = inv.getStackInSlot(i).getItem();
        if (stack.getRegistryName() != null && stack.getRegistryName().equals(item.getRegistryName())) {
            stackInInventory = inv.getStackInSlot(i);
            stackIndex = i;
            blockInInventory = true;
        }
    }

    // We don't have that item in our inventories
    if (!blockInInventory)
        return false;

    RayTraceResult mop = Minecraft.getMinecraft().objectMouseOver;
    if (mop.typeOfHit == RayTraceResult.Type.BLOCK) {
        BlockPos pos = mop.getBlockPos().add(mop.sideHit.getDirectionVec());
        // Can we place this block here?
        AxisAlignedBB axisalignedbb = block.getDefaultState().getCollisionBoundingBox(player.world, pos);
        if (axisalignedbb == null || player.world.checkNoEntityCollision(axisalignedbb.offset(pos), null)) {
            MalmoMod.network.sendToServer(new DiscreteMovementCommandsImplementation.UseActionMessage(mop.getBlockPos(), new ItemStack(block), mop.sideHit, false, mop.hitVec));
            if (stackInInventory.getCount() == 1)
                inv.setInventorySlotContents(stackIndex, new ItemStack(Block.getBlockById(0)));
            else
                stackInInventory.setCount(stackInInventory.getCount() - 1);
        }
    }

    return true;
}