use of net.minecraft.block.BlockVine 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.BlockVine in project BiomesOPlenty by Glitchfiend.
the class GeneratorTreeBase method setVine.
public boolean setVine(World world, Random rand, BlockPos pos, EnumFacing side, int length) {
if (this.vine == null) {
return false;
}
IBlockState vineState = this.vine.getBlock() instanceof BlockVine ? this.vine.withProperty(BlockVine.NORTH, Boolean.valueOf(side == EnumFacing.NORTH)).withProperty(BlockVine.EAST, Boolean.valueOf(side == EnumFacing.EAST)).withProperty(BlockVine.SOUTH, Boolean.valueOf(side == EnumFacing.SOUTH)).withProperty(BlockVine.WEST, Boolean.valueOf(side == EnumFacing.WEST)) : this.vine;
boolean setOne = false;
while (world.getBlockState(pos).getBlock().isAir(world.getBlockState(pos), world, pos) && length > 0 && rand.nextInt(12) > 0) {
world.setBlockState(pos, vineState, 2);
setOne = true;
length--;
pos = pos.down();
}
return setOne;
}
use of net.minecraft.block.BlockVine in project BiomesOPlenty by Glitchfiend.
the class GeneratorVines method generate.
@Override
public boolean generate(World world, Random rand, BlockPos pos) {
boolean ret = true;
for (int i = 0; i < this.generationAttempts; ++i) {
BlockPos genPos = pos.add(rand.nextInt(4) - rand.nextInt(4), rand.nextInt(3) - rand.nextInt(3), rand.nextInt(4) - rand.nextInt(4));
if (!this.replace.matches(world, genPos) || !this.placeOn.matches(world, genPos.up()))
continue;
IBlockState vineState = this.with;
// make sure there is an adjacent block for the vine to attach to
List<EnumFacing> validDirections = Lists.newArrayList();
for (EnumFacing facing : EnumFacing.values()) {
if (facing == EnumFacing.UP || facing == EnumFacing.DOWN)
continue;
if (this.placeOn.matches(world, genPos.offset(facing)))
validDirections.add(facing);
}
if (validDirections.isEmpty())
continue;
if (this.with.getBlock() instanceof BlockVine) {
EnumFacing direction = validDirections.get(rand.nextInt(validDirections.size()));
vineState = this.with.withProperty(BlockVine.getPropertyFor(direction), Boolean.valueOf(true));
}
// choose random target height
int targetHeight = GeneratorUtils.nextIntBetween(rand, this.minHeight, this.maxHeight);
// keep placing blocks upwards (if there's room)
for (int height = 0; height <= targetHeight; height++) {
BlockPos offsetPos = genPos.down(height);
if (replace.matches(world, offsetPos) && vineState.getBlock().canPlaceBlockAt(world, offsetPos)) {
world.setBlockState(offsetPos, vineState);
} else {
ret = false;
break;
}
}
}
return ret;
}
use of net.minecraft.block.BlockVine in project Wurst-MC-1.12 by Wurst-Imperium.
the class WalkPathProcessor method process.
@Override
public void process() {
// get positions
BlockPos pos;
if (WMinecraft.getPlayer().onGround)
pos = new BlockPos(WMinecraft.getPlayer().posX, WMinecraft.getPlayer().posY + 0.5, WMinecraft.getPlayer().posZ);
else
pos = new BlockPos(WMinecraft.getPlayer());
PathPos nextPos = path.get(index);
int posIndex = path.indexOf(pos);
if (posIndex == -1)
ticksOffPath++;
else
ticksOffPath = 0;
// update index
if (pos.equals(nextPos)) {
index++;
// disable when done
if (index >= path.size())
done = true;
return;
} else if (posIndex > index) {
index = posIndex + 1;
// disable when done
if (index >= path.size())
done = true;
return;
}
lockControls();
WMinecraft.getPlayer().capabilities.isFlying = false;
// face next position
facePosition(nextPos);
if (WMath.wrapDegrees(Math.abs(RotationUtils.getHorizontalAngleToClientRotation(new Vec3d(nextPos).addVector(0.5, 0.5, 0.5)))) > 90)
return;
if (wurst.mods.jesusMod.isActive()) {
// wait for Jesus to swim up
if (WMinecraft.getPlayer().posY < nextPos.getY() && (WMinecraft.getPlayer().isInWater() || WMinecraft.getPlayer().isInLava()))
return;
// manually swim down if using Jesus
if (WMinecraft.getPlayer().posY - nextPos.getY() > 0.5 && (WMinecraft.getPlayer().isInWater() || WMinecraft.getPlayer().isInLava() || wurst.mods.jesusMod.isOverLiquid()))
mc.gameSettings.keyBindSneak.pressed = true;
}
// horizontal movement
if (pos.getX() != nextPos.getX() || pos.getZ() != nextPos.getZ()) {
mc.gameSettings.keyBindForward.pressed = true;
if (index > 0 && path.get(index - 1).isJumping() || pos.getY() < nextPos.getY())
mc.gameSettings.keyBindJump.pressed = true;
// vertical movement
} else if (pos.getY() != nextPos.getY())
// go up
if (pos.getY() < nextPos.getY()) {
// climb up
// TODO: Spider
Block block = WBlock.getBlock(pos);
if (block instanceof BlockLadder || block instanceof BlockVine) {
RotationUtils.faceVectorForWalking(WBlock.getBoundingBox(pos).getCenter());
mc.gameSettings.keyBindForward.pressed = true;
} else {
// directional jump
if (index < path.size() - 1 && !nextPos.up().equals(path.get(index + 1)))
index++;
// jump up
mc.gameSettings.keyBindJump.pressed = true;
}
// go down
} else {
// skip mid-air nodes and go straight to the bottom
while (index < path.size() - 1 && path.get(index).down().equals(path.get(index + 1))) index++;
// walk off the edge
if (WMinecraft.getPlayer().onGround)
mc.gameSettings.keyBindForward.pressed = true;
}
}
Aggregations