use of forestry.greenhouse.api.greenhouse.Position2D in project ForestryMC by ForestryMC.
the class GreenhouseController method createLimits.
private IGreenhouseLimits createLimits() {
BlockPos centerTop = getTopCenterCoord();
centerPos = centerTop.up(CENTER_HEIGHT);
BlockPos max = getMaximumCoord();
BlockPos min = getMinimumCoord();
int sizeNorthSouth = Math.abs(max.getZ() - min.getZ()) + 1;
int sizeEastWest = Math.abs(max.getX() - min.getX()) + 1;
int height = (Math.abs(max.getY() - min.getY()) + 2) * Config.greenhouseSize;
int lengthEastWest = sizeEastWest * Config.greenhouseSize;
int lengthNorthSouth = sizeNorthSouth * Config.greenhouseSize;
return new GreenhouseLimits(new Position2D(lengthEastWest, lengthNorthSouth), new Position2D(-lengthEastWest, -lengthNorthSouth), height, REGION_DEPTH);
}
use of forestry.greenhouse.api.greenhouse.Position2D in project ForestryMC by ForestryMC.
the class ClimateSourceWorldManager method removeSource.
public void removeSource(IClimateSourceOwner owner) {
BlockPos pos = owner.getCoordinates();
Position2D position = new Position2D(pos);
Map<Integer, IClimateSourceOwner> positionedOwners = owners.computeIfAbsent(position, k -> new HashMap<>());
positionedOwners.remove(pos.getY());
}
use of forestry.greenhouse.api.greenhouse.Position2D in project ForestryMC by ForestryMC.
the class ClimateSourceWorldManager method addSource.
public void addSource(IClimateSourceOwner owner) {
BlockPos pos = owner.getCoordinates();
Position2D position = new Position2D(pos);
Map<Integer, IClimateSourceOwner> positionedOwners = owners.computeIfAbsent(position, k -> new HashMap<>());
positionedOwners.put(pos.getY(), owner);
}
use of forestry.greenhouse.api.greenhouse.Position2D in project ForestryMC by ForestryMC.
the class WallBlock method onCreate.
@Override
public void onCreate() {
IClimateContainer container = provider.getClimateContainer();
for (IClimateSourceOwner sourceOwner : GreenhouseManager.climateManager.getSources(provider.getWorld(), new Position2D(pos))) {
IClimateSource source = sourceOwner.getClimateSource();
sources.add(source);
container.addClimateSource(source);
source.onAdded(container);
}
}
use of forestry.greenhouse.api.greenhouse.Position2D in project ForestryMC by ForestryMC.
the class GreenhouseEventHandler method onWorldRenderLast.
@SubscribeEvent
public void onWorldRenderLast(RenderWorldLastEvent event) {
try {
float partialTicks = event.getPartialTicks();
EntityPlayer player = Minecraft.getMinecraft().player;
World world = player.world;
long tick = world.getTotalWorldTime();
if (tick > previousCheckTick + 50) {
greenhousePositions.clear();
for (ItemStack itemStack : getClimateScreen(player.inventory)) {
if (!itemStack.isEmpty()) {
BlockPos position = ItemGreenhouseScreen.getGreenhousePos(itemStack);
IGreenhouseControllerInternal controller = MultiblockUtil.getController(world, position, IGreenhouseComponent.class);
if (controller == null || !controller.isAssembled()) {
return;
}
position = controller.getCenterCoordinates();
double distance = MathHelper.sqrt(player.getDistanceSqToCenter(position));
if (distance > 64F) {
return;
}
greenhousePositions.add(position);
}
}
previousCheckTick = tick;
}
for (BlockPos position : greenhousePositions) {
IGreenhouseControllerInternal controller = MultiblockUtil.getController(world, position, IGreenhouseComponent.class);
if (controller == null || !controller.isAssembled()) {
continue;
}
IGreenhouseProvider provider = controller.getProvider();
position = controller.getCenterCoordinates();
double distance = MathHelper.sqrt(player.getDistanceSqToCenter(position));
if (distance > 64F) {
return;
}
double playerX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
double playerY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
double playerZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
GlStateManager.pushMatrix();
GlStateManager.translate(-playerX, -playerY, -playerZ);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.disableTexture2D();
GlStateManager.glLineWidth(2.5F);
// Draw center position
BlockPos offset = provider.getCenterPos();
AxisAlignedBB testBlockBB = Block.FULL_BLOCK_AABB.offset(offset);
RenderGlobal.drawSelectionBoundingBox(testBlockBB, 0.0F, 0.0F, 0.0F, 0.5F);
IGreenhouseLimits limits = provider.getUsedLimits();
if (limits != null) {
Position2D minEdge = limits.getMinimumCoordinates();
Position2D maxEdge = limits.getMaximumCoordinates();
AxisAlignedBB greenhouseBB = new AxisAlignedBB(minEdge.getX(), limits.getDepth(), minEdge.getZ(), maxEdge.getX() + 1, limits.getHeight() + 1, maxEdge.getZ() + 1);
RenderGlobal.drawSelectionBoundingBox(greenhouseBB, 0.0F, 0.0F, 0.0F, 0.5F);
}
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations