Search in sources :

Example 1 with IDispenseItemBehavior

use of net.minecraft.dispenser.IDispenseItemBehavior in project MCMOD-Industria by M-Marvin.

the class ServerSetup method setup.

@SubscribeEvent
@SuppressWarnings("deprecation")
public static void setup(final FMLCommonSetupEvent event) {
    // Dispenser Behaviors
    IDispenseItemBehavior placeBlockBehavior = new IDispenseItemBehavior() {

        @Override
        public ItemStack dispense(IBlockSource source, ItemStack stack) {
            BlockPos pos = source.getPos().relative(source.getBlockState().getValue(BlockStateProperties.FACING));
            Block block = Block.byItem(stack.getItem());
            if (block != null && (source.getLevel().getBlockState(pos).isAir() || source.getLevel().getBlockState(pos).getBlock() instanceof FlowingFluidBlock) && block.canSurvive(block.defaultBlockState(), source.getLevel(), pos)) {
                source.getLevel().setBlockAndUpdate(pos, block.defaultBlockState());
                stack.shrink(1);
                return stack;
            }
            return stack;
        }
    };
    Registry.BLOCK.stream().forEach((block) -> {
        Item item = Item.byBlock(block);
        if (item != null) {
            if (item != Items.TNT)
                DispenserBlock.registerBehavior(item, placeBlockBehavior);
        }
    });
// Vanilla FireInfo Overrides
// MethodHelper.addFireSetting(Blocks.ACACIA_DOOR, 5, 20);
// MethodHelper.addFireSetting(Blocks.OAK_DOOR, 5, 20);
// MethodHelper.addFireSetting(Blocks.BIRCH_DOOR, 5, 20);
// MethodHelper.addFireSetting(Blocks.DARK_OAK_DOOR, 5, 20);
// MethodHelper.addFireSetting(Blocks.SPRUCE_DOOR, 5, 20);
// MethodHelper.addFireSetting(Blocks.CHEST, 5, 20);
// MethodHelper.addFireSetting(Blocks.TRAPPED_CHEST, 5, 20);
// MethodHelper.addFireSetting(Blocks.OAK_TRAPDOOR, 5, 20);
// MethodHelper.addFireSetting(Blocks.BIRCH_TRAPDOOR, 5, 20);
// MethodHelper.addFireSetting(Blocks.ACACIA_TRAPDOOR, 5, 20);
// MethodHelper.addFireSetting(Blocks.DARK_OAK_TRAPDOOR, 5, 20);
// MethodHelper.addFireSetting(Blocks.SPRUCE_TRAPDOOR, 5, 20);
// MethodHelper.addFireSetting(Blocks.OAK_SIGN, 10, 30);
// MethodHelper.addFireSetting(Blocks.BIRCH_SIGN, 10, 30);
// MethodHelper.addFireSetting(Blocks.ACACIA_SIGN, 10, 30);
// MethodHelper.addFireSetting(Blocks.DARK_OAK_SIGN, 10, 30);
// MethodHelper.addFireSetting(Blocks.SPRUCE_SIGN, 10, 30);
// MethodHelper.addFireSetting(Blocks.OAK_PRESSURE_PLATE, 10, 30);
// MethodHelper.addFireSetting(Blocks.BIRCH_PRESSURE_PLATE, 10, 30);
// MethodHelper.addFireSetting(Blocks.ACACIA_PRESSURE_PLATE, 10, 30);
// MethodHelper.addFireSetting(Blocks.DARK_OAK_PRESSURE_PLATE, 10, 30);
// MethodHelper.addFireSetting(Blocks.SPRUCE_PRESSURE_PLATE, 10, 30);
}
Also used : Item(net.minecraft.item.Item) FlowingFluidBlock(net.minecraft.block.FlowingFluidBlock) IBlockSource(net.minecraft.dispenser.IBlockSource) IDispenseItemBehavior(net.minecraft.dispenser.IDispenseItemBehavior) Block(net.minecraft.block.Block) FlowingFluidBlock(net.minecraft.block.FlowingFluidBlock) DispenserBlock(net.minecraft.block.DispenserBlock) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

Block (net.minecraft.block.Block)1 DispenserBlock (net.minecraft.block.DispenserBlock)1 FlowingFluidBlock (net.minecraft.block.FlowingFluidBlock)1 IBlockSource (net.minecraft.dispenser.IBlockSource)1 IDispenseItemBehavior (net.minecraft.dispenser.IDispenseItemBehavior)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.math.BlockPos)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1