use of com.minecolonies.coremod.blocks.BlockHutField in project minecolonies by Minecolonies.
the class TileEntityScarecrowRenderer method renderTileEntityAt.
@Override
public void renderTileEntityAt(@NotNull final ScarecrowTileEntity te, final double posX, final double posY, final double posZ, final float partialTicks, final int destroyStage) {
//Store the transformation
GlStateManager.pushMatrix();
//Set viewport to tile entity position to render it
GlStateManager.translate(posX + BLOCK_MIDDLE, posY + YOFFSET, posZ + BLOCK_MIDDLE);
this.bindTexture(getResourceLocation(te));
GlStateManager.rotate(ROTATION, XROTATIONOFFSET, YROTATIONOFFSET, ZROTATIONOFFSET);
//In the case of worldLags tileEntities may sometimes disappear.
if (getWorld().getBlockState(te.getPos()).getBlock() instanceof BlockHutField) {
final EnumFacing facing = getWorld().getBlockState(te.getPos()).getValue(BlockHutField.FACING);
switch(facing) {
case EAST:
GlStateManager.rotate((float) (BASIC_ROTATION * ROTATE_EAST), 0, 1, 0);
break;
case SOUTH:
GlStateManager.rotate((float) (BASIC_ROTATION * ROTATE_SOUTH), 0, 1, 0);
break;
case WEST:
GlStateManager.rotate((float) (BASIC_ROTATION * ROTATE_WEST), 0, 1, 0);
break;
default:
}
}
this.model.render((float) SIZERATIO);
/* ============ Rendering Code stops here =========== */
//Restore the transformation, so other renderer's are not messed up.
GlStateManager.popMatrix();
}
use of com.minecolonies.coremod.blocks.BlockHutField in project minecolonies by Minecolonies.
the class AbstractPathJob method prepareStart.
/**
* Generates a good path starting location for the entity to path from, correcting for the following conditions.
* - Being in water: pathfinding in water occurs along the surface; adjusts position to surface.
* - Being in a fence space: finds correct adjacent position which is not a fence space, to prevent starting path.
* from within the fence block.
*
* @param entity Entity for the pathfinding operation.
* @return ChunkCoordinates for starting location.
*/
public static BlockPos prepareStart(@NotNull final EntityLiving entity) {
@NotNull final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(MathHelper.floor(entity.posX), (int) entity.posY, MathHelper.floor(entity.posZ));
IBlockState bs = entity.world.getBlockState(pos);
final Block b = bs.getBlock();
if (entity.isInWater()) {
while (bs.getMaterial().isLiquid()) {
pos.setPos(pos.getX(), pos.getY() + 1, pos.getZ());
bs = entity.world.getBlockState(pos);
}
} else if (b instanceof BlockFence || b instanceof BlockWall || b instanceof BlockHutField) {
//Push away from fence
final double dX = entity.posX - Math.floor(entity.posX);
final double dZ = entity.posZ - Math.floor(entity.posZ);
if (dX < TOO_CLOSE_TO_FENCE) {
pos.setPos(pos.getX() - 1, pos.getY(), pos.getZ());
} else if (dX > TOO_FAR_FROM_FENCE) {
pos.setPos(pos.getX() + 1, pos.getY(), pos.getZ());
}
if (dZ < TOO_CLOSE_TO_FENCE) {
pos.setPos(pos.getX(), pos.getY(), pos.getZ() - 1);
} else if (dZ > TOO_FAR_FROM_FENCE) {
pos.setPos(pos.getX(), pos.getY(), pos.getZ() + 1);
}
}
return pos.toImmutable();
}
Aggregations