use of net.minecraft.block.BlockLog in project SpongeCommon by SpongePowered.
the class MixinBlock method onConstruction.
@Inject(method = "<init>*", at = @At("RETURN"))
public void onConstruction(CallbackInfo ci) {
// Determine which blocks can avoid executing un-needed event logic
// This will allow us to avoid running event logic for blocks that do nothing such as grass collisions
// -- blood
this.hasCollideLogic = true;
this.hasCollideWithStateLogic = true;
// onEntityCollidedWithBlock
try {
String mapping = SpongeImplHooks.isDeobfuscatedEnvironment() ? "onEntityWalk" : "func_176199_a";
Class<?>[] argTypes = { net.minecraft.world.World.class, BlockPos.class, Entity.class };
Class<?> clazz = this.getClass().getMethod(mapping, argTypes).getDeclaringClass();
if (clazz.equals(Block.class)) {
this.hasCollideLogic = false;
}
} catch (Throwable ex) {
// ignore
}
// onEntityCollidedWithBlock (IBlockState)
try {
String mapping = SpongeImplHooks.isDeobfuscatedEnvironment() ? "onEntityCollidedWithBlock" : "func_180634_a";
Class<?>[] argTypes = { net.minecraft.world.World.class, BlockPos.class, IBlockState.class, Entity.class };
Class<?> clazz = this.getClass().getMethod(mapping, argTypes).getDeclaringClass();
if (clazz.equals(Block.class)) {
this.hasCollideWithStateLogic = false;
}
} catch (Throwable ex) {
// ignore
}
Block block = (Block) (Object) this;
if (block instanceof BlockLeaves || block instanceof BlockLog || block instanceof BlockGrass || block instanceof BlockLiquid) {
this.requiresBlockCapture = false;
}
}
use of net.minecraft.block.BlockLog in project ForestryMC by ForestryMC.
the class BlockHumus method isEnrooted.
private static boolean isEnrooted(World world, BlockPos pos) {
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
if (i == 0 && j == 0) {
// We are not returning true if we are the base of a sapling.
continue;
}
BlockPos blockPos = pos.add(i, 1, j);
IBlockState state = world.getBlockState(blockPos);
Block block = state.getBlock();
if (block instanceof BlockLog || block instanceof IGrowable) {
return true;
}
}
}
return false;
}
use of net.minecraft.block.BlockLog in project MC-Prefab by Brian-Wuest.
the class BuildBlock method setComparable.
private static Comparable setComparable(Comparable<?> comparable, Block foundBlock, IProperty<?> property, StructureConfiguration configuration, BuildBlock block, EnumFacing assumedNorth, Optional<?> propertyValue, EnumFacing vineFacing, EnumAxis logFacing, Axis boneFacing, BlockQuartz.EnumType quartzFacing, EnumOrientation leverOrientation, Structure structure) {
if (property.getName().equals("facing") && !(foundBlock instanceof BlockLever)) {
// Facing properties should be relative to the configuration facing.
EnumFacing facing = EnumFacing.byName(propertyValue.get().toString());
// Cannot rotate verticals.
if (facing != null && facing != EnumFacing.UP && facing != EnumFacing.DOWN) {
if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().rotateY()) {
facing = facing.rotateY();
} else if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().getOpposite()) {
facing = facing.getOpposite();
} else if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().rotateYCCW()) {
facing = facing.rotateYCCW();
}
}
comparable = facing;
block.setHasFacing(true);
} else if (property.getName().equals("facing") && foundBlock instanceof BlockLever) {
comparable = leverOrientation;
block.setHasFacing(true);
} else if (property.getName().equals("rotation")) {
// 0 = South
// 4 = West
// 8 = North
// 12 = East
int rotation = (Integer) propertyValue.get();
EnumFacing facing = rotation == 0 ? EnumFacing.SOUTH : rotation == 4 ? EnumFacing.WEST : rotation == 8 ? EnumFacing.NORTH : EnumFacing.EAST;
if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().rotateY()) {
facing = facing.rotateY();
} else if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().getOpposite()) {
facing = facing.getOpposite();
} else if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().rotateYCCW()) {
facing = facing.rotateYCCW();
}
rotation = facing == EnumFacing.SOUTH ? 0 : facing == EnumFacing.WEST ? 4 : facing == EnumFacing.NORTH ? 8 : 12;
comparable = rotation;
block.setHasFacing(true);
} else if (foundBlock instanceof BlockVine) {
// Vines have a special state. There is 1 property for each "facing".
if (property.getName().equals(vineFacing.getName2())) {
comparable = true;
block.setHasFacing(true);
} else {
comparable = false;
}
} else if (foundBlock instanceof BlockWall) {
if (!property.getName().equals("variant")) {
if (property.getName().equals(vineFacing.getName2()) || property.getName().equals(vineFacing.getOpposite().getName2())) {
comparable = true;
block.setHasFacing(true);
} else {
comparable = false;
}
}
} else if (foundBlock instanceof BlockLog) {
// logs have a special state. There is a property called axis and it only has 3 directions.
if (property.getName().equals("axis")) {
comparable = logFacing;
}
} else if (foundBlock instanceof BlockBone) {
// bones have a special state. There is a property called axis and it only has 3 directions.
if (property.getName().equals("axis")) {
comparable = boneFacing;
}
} else if (foundBlock instanceof BlockQuartz) {
if (property.getName().equals("variant") && quartzFacing != BlockQuartz.EnumType.DEFAULT) {
comparable = quartzFacing;
}
}
return comparable;
}
use of net.minecraft.block.BlockLog in project DynamicSurroundings by OreCruncher.
the class FootstepsRegistry method seedMap.
private void seedMap() {
// Iterate through the blockmap looking for known pattern types.
// Though they probably should all be registered with Forge
// dictionary it's not a requirement.
final Iterator<Block> itr = Block.REGISTRY.iterator();
while (itr.hasNext()) {
final Block block = itr.next();
final String blockName = MCHelper.nameOf(block);
if (block instanceof BlockCrops) {
final BlockCrops crop = (BlockCrops) block;
if (crop.getMaxAge() == 3) {
registerBlocks("#beets", blockName);
} else if (blockName.equals("minecraft:wheat")) {
registerBlocks("#wheat", blockName);
} else if (crop.getMaxAge() == 7) {
registerBlocks("#crop", blockName);
}
} else if (block instanceof BlockSapling) {
registerBlocks("#sapling", blockName);
} else if (block instanceof BlockReed) {
registerBlocks("#reed", blockName);
} else if (block instanceof BlockFence) {
registerBlocks("#fence", blockName);
} else if (block instanceof BlockFlower || block instanceof BlockMushroom) {
registerBlocks("NOT_EMITTER", blockName);
} else if (block instanceof BlockLog || block instanceof BlockPlanks) {
registerBlocks("wood", blockName);
} else if (block instanceof BlockDoor) {
registerBlocks("bluntwood", blockName);
} else if (block instanceof BlockLeaves) {
registerBlocks("leaves", blockName);
} else if (block instanceof BlockOre) {
registerBlocks("ore", blockName);
} else if (block instanceof BlockIce) {
registerBlocks("ice", blockName);
}
}
}
use of net.minecraft.block.BlockLog in project BetterWithAddons by DaedalusGame.
the class WorldGenBigTrees method limb.
void limb(BlockPos pos1, BlockPos pos2) {
BlockPos blockpos = pos2.add(-pos1.getX(), -pos1.getY(), -pos1.getZ());
int i = this.getGreatestDistance(blockpos);
float f = (float) blockpos.getX() / (float) i;
float f1 = (float) blockpos.getY() / (float) i;
float f2 = (float) blockpos.getZ() / (float) i;
for (int j = 0; j <= i; ++j) {
BlockPos blockpos1 = pos1.add((double) (0.5F + (float) j * f), (double) (0.5F + (float) j * f1), (double) (0.5F + (float) j * f2));
BlockLog.EnumAxis blocklog$enumaxis = this.getLogAxis(pos1, blockpos1);
this.setBlockAndNotifyAdequately(this.world, blockpos1, log.withProperty(BlockLog.LOG_AXIS, blocklog$enumaxis));
}
}
Aggregations