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);
}
Aggregations