use of net.minecraft.block.material.Material in project BetterWithAddons by DaedalusGame.
the class StumpingHandler method breakBlock.
@SubscribeEvent
public void breakBlock(PlayerEvent.BreakSpeed breakEvent) {
World world = breakEvent.getEntity().getEntityWorld();
BlockPos breakpos = breakEvent.getPos();
IBlockState state = world.getBlockState(breakpos);
Block block = state.getBlock();
float speed = breakEvent.getNewSpeed();
float multiplier = 1f;
boolean issoft = false;
if (InteractionBTWTweak.HARD_STUMPS) {
if (block instanceof BlockLog && !issoft) {
IBlockState bottomstate = world.getBlockState(breakpos.down());
Material material = bottomstate.getMaterial();
if (material == Material.GROUND || material == Material.GRASS)
multiplier = 0.1f;
}
}
if (InteractionBTWTweak.SOFT_WOODS) {
int meta = block.damageDropped(state);
for (WoodHardness wood : SOFT_WOODS) {
if (wood.matches(block, meta)) {
multiplier = wood.hardness / state.getBlockHardness(world, breakpos);
break;
}
}
}
breakEvent.setNewSpeed(speed * multiplier);
}
use of net.minecraft.block.material.Material in project RecurrentComplex by Ivorforce.
the class RCRegistryHandler method preInit.
public static void preInit(FMLPreInitializationEvent event, RecurrentComplex mod) {
if (!RecurrentComplex.isLite()) {
tabStructureTools = new CreativeTabs("structureTools") {
@Override
public ItemStack getTabIconItem() {
return new ItemStack(RCItems.blockSelector);
}
};
tabInventoryGenerators = new CreativeTabs("inventoryGenerators") {
@Override
public ItemStack getTabIconItem() {
return new ItemStack(RCItems.inventoryGenerationTag);
}
};
}
RCMaterials.materialNegativeSpace = new MaterialNegativeSpace();
RCMaterials.materialGenericSolid = (new Material(MapColor.STONE));
CapabilityManager.INSTANCE.register(RCEntityInfo.class, new NBTCompoundObjectCapabilityStorage<>(RCEntityInfo.class), RCEntityInfo::new);
CapabilityManager.INSTANCE.register(CapabilitySelection.class, new NBTCompoundObjectCapabilityStorage<>(CapabilitySelection.class), CapabilitySelection::new);
blockSelector = new ItemBlockSelectorBlock().setUnlocalizedName("blockSelector");
blockSelector.setCreativeTab(tabStructureTools);
register(blockSelector, "block_selector");
RecurrentComplex.cremapper.registerLegacyIDs(blockSelector, "blockSelector");
blockSelectorFloating = new ItemBlockSelectorFloating().setUnlocalizedName("blockSelectorFloating");
blockSelectorFloating.setCreativeTab(tabStructureTools);
register(blockSelectorFloating, "block_selector_floating");
RecurrentComplex.cremapper.registerLegacyIDs(blockSelectorFloating, "blockSelectorFloating");
inventoryGenerationTag = (ItemInventoryGenMultiTag) new ItemInventoryGenMultiTag().setUnlocalizedName("inventoryGenerationTag");
inventoryGenerationTag.setCreativeTab(tabInventoryGenerators);
register(inventoryGenerationTag, "inventory_generation_tag");
RecurrentComplex.cremapper.registerLegacyIDs(inventoryGenerationTag, "inventoryGenerationTag");
inventoryGenerationSingleTag = (ItemInventoryGenSingleTag) new ItemInventoryGenSingleTag().setUnlocalizedName("inventoryGenerationSingleTag");
inventoryGenerationSingleTag.setCreativeTab(tabInventoryGenerators);
register(inventoryGenerationSingleTag, "inventory_generation_single_tag");
RecurrentComplex.cremapper.registerLegacyIDs(inventoryGenerationSingleTag, "inventoryGenerationSingleTag");
inventoryGenerationComponentTag = (ItemInventoryGenComponentTag) new ItemInventoryGenComponentTag().setUnlocalizedName("inventoryGenerationComponentTag");
inventoryGenerationComponentTag.setCreativeTab(tabInventoryGenerators);
register(inventoryGenerationComponentTag, "inventory_generation_component_tag");
artifactGenerationTag = new ItemArtifactGenerator().setUnlocalizedName("artifactGenerationTag");
artifactGenerationTag.setCreativeTab(tabInventoryGenerators);
register(artifactGenerationTag, "artifact_generation_tag");
RecurrentComplex.cremapper.registerLegacyIDs(artifactGenerationTag, "artifactGenerationTag");
bookGenerationTag = new ItemBookGenerator().setUnlocalizedName("bookGenerationTag");
bookGenerationTag.setCreativeTab(tabInventoryGenerators);
register(bookGenerationTag, "book_generation_tag");
RecurrentComplex.cremapper.registerLegacyIDs(bookGenerationTag, "bookGenerationTag");
genericSpace = (BlockGenericSpace) new BlockGenericSpace().setUnlocalizedName("negativeSpace");
genericSpace.setCreativeTab(tabStructureTools);
register(genericSpace, "generic_space", new ItemBlockGenericSpace(genericSpace));
RecurrentComplex.cremapper.registerLegacyIDs(genericSpace, true, "negativeSpace");
genericSolid = new BlockGenericSolid().setUnlocalizedName("naturalFloor");
genericSolid.setCreativeTab(tabStructureTools);
register(genericSolid, "generic_solid", new ItemBlockGenericSolid(genericSolid));
RecurrentComplex.cremapper.registerLegacyIDs(genericSolid, true, "naturalFloor");
structureGenerator = new BlockStructureGenerator().setUnlocalizedName("structureGenerator");
register(structureGenerator, "structure_generator");
register(BlockStructureGenerator.TileEntityStructureGenerator.class, "RCStructureGenerator", "SGStructureGenerator");
RecurrentComplex.cremapper.registerLegacyIDs(structureGenerator, true, "structureGenerator");
mazeGenerator = new BlockMazeGenerator().setUnlocalizedName("mazeGenerator");
register(mazeGenerator, "maze_generator");
register(BlockMazeGenerator.TileEntityMazeGenerator.class, "RCMazeGenerator", "SGMazeGenerator");
RecurrentComplex.cremapper.registerLegacyIDs(mazeGenerator, true, "mazeGenerator");
spawnCommands = new BlockSpawnCommand().setUnlocalizedName("spawn_command");
register(spawnCommands, "weighted_command_block");
register(BlockSpawnCommand.TileEntitySpawnCommand.class, "RCSpawnCommand");
RecurrentComplex.cremapper.registerLegacyIDs(spawnCommands, true, "spawnCommand");
spawnScript = new BlockScript().setUnlocalizedName("spawn_script");
spawnScript.setCreativeTab(tabStructureTools);
register(spawnScript, "spawn_script");
register(TileEntityBlockScript.class, "RCSpawnScript");
inspector = new ItemInspector().setUnlocalizedName("recinspector");
inspector.setCreativeTab(tabStructureTools);
register(inspector, "inspector");
// Set preset defaults
GenericPlacerPresets.instance().getRegistry().register("clear", MOD_ID, PresetRegistry.fullPreset("clear", new GenericPlacer(), new PresetRegistry.Metadata("Clear", "Do not place anywhere")), true, LeveledRegistry.Level.INTERNAL);
GenericPlacerPresets.instance().setDefault("clear");
DimensionMatcherPresets.instance().getRegistry().register("clear", MOD_ID, PresetRegistry.fullPreset("clear", new ArrayList<>(), new PresetRegistry.Metadata("None", "No dimensions")), true, LeveledRegistry.Level.INTERNAL);
DimensionMatcherPresets.instance().setDefault("clear");
BiomeMatcherPresets.instance().getRegistry().register("clear", MOD_ID, PresetRegistry.fullPreset("clear", new ArrayList<>(), new PresetRegistry.Metadata("None", "No biomes")), true, LeveledRegistry.Level.INTERNAL);
BiomeMatcherPresets.instance().setDefault("clear");
WeightedBlockStatePresets.instance().getRegistry().register("clear", MOD_ID, PresetRegistry.fullPreset("clear", new ArrayList<>(), new PresetRegistry.Metadata("None", "No blocks")), true, LeveledRegistry.Level.INTERNAL);
WeightedBlockStatePresets.instance().setDefault("clear");
TransfomerPresets.instance().getRegistry().register("clear", MOD_ID, PresetRegistry.fullPreset("clear", new TransformerMulti.Data(), new PresetRegistry.Metadata("None", "No transformers")), true, LeveledRegistry.Level.INTERNAL);
TransfomerPresets.instance().setDefault("clear");
GenerationSanityChecker.init();
}
use of net.minecraft.block.material.Material in project Railcraft by Railcraft.
the class ItemFluidContainer method tryPlaceContainedLiquid.
private boolean tryPlaceContainedLiquid(World world, BlockPos pos) {
Fluid fl = fluid.get();
if (fl == null)
return false;
Block fluidBlock = fl.getBlock();
if (fluidBlock == null)
return false;
Material material = WorldPlugin.getBlockMaterial(world, pos);
if (!world.isAirBlock(pos) && material.isSolid())
return false;
if (!world.isRemote && !material.isSolid() && !material.isLiquid())
world.destroyBlock(pos, true);
world.setBlockState(pos, fluidBlock.getDefaultState().withProperty(BlockFluidBase.LEVEL, fluidBlock instanceof BlockFluidFinite ? 15 : 0));
return true;
}
use of net.minecraft.block.material.Material in project Realistic-Terrain-Generation by Team-RTG.
the class WorldUtil method isBlockAbove.
/**
* Checks to see if a given block is above a given coordinate.
* Use isSurroundedByBlock() with SurroundCheckType.UP if you want to check all blocks above.
*/
public boolean isBlockAbove(IBlockState checkBlock, int checkDistance, World world, int x, int y, int z, boolean materialCheck) {
Material checkBlockMaterial = checkBlock.getMaterial();
IBlockState blockAbove;
Material m;
for (int i = 1; i <= checkDistance; i++) {
blockAbove = world.getBlockState(new BlockPos(x, y + checkDistance, z));
if (materialCheck) {
m = blockAbove.getMaterial();
if (m != checkBlockMaterial) {
return false;
}
} else if (blockAbove != checkBlock) {
return false;
}
}
return true;
}
use of net.minecraft.block.material.Material in project Engine by VoltzEngine-Project.
the class ItemFluidBucket method tryPlaceContainedLiquid.
/**
* Attempts to place the liquid contained inside the bucket.
*/
public boolean tryPlaceContainedLiquid(ItemStack stack, World world, int x, int y, int z) {
FluidStack fluidStack = this.getFluid(stack);
if (fluidStack != null && fluidStack.getFluid() != null && fluidStack.getFluid().getBlock() != null) {
Material material = world.getBlock(x, y, z).getMaterial();
boolean flag = !material.isSolid();
if (!world.isAirBlock(x, y, z) && !flag) {
return false;
} else {
if (!world.isRemote && flag && !material.isLiquid()) {
world.func_147480_a(x, y, z, true);
}
world.setBlock(x, y, z, fluidStack.getFluid().getBlock(), 0, 3);
return true;
}
}
return false;
}
Aggregations