use of net.minecraft.util.math.Vec3i in project BuildCraft by BuildCraft.
the class Box method expand.
@Override
public Box expand(int amount) {
if (!isInitialized())
return this;
Vec3i am = new BlockPos(amount, amount, amount);
setMin(min().subtract(am));
setMax(max().add(am));
return this;
}
use of net.minecraft.util.math.Vec3i in project MorePlanets by SteveKunG.
the class ClientRendererUtils method renderModelBrightnessColorQuads.
private static void renderModelBrightnessColorQuads(float brightness, float red, float green, float blue, List<BakedQuad> listQuads) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder vertexbuffer = tessellator.getBuffer();
int i = 0;
for (int j = listQuads.size(); i < j; ++i) {
BakedQuad bakedquad = listQuads.get(i);
vertexbuffer.begin(GLConstants.QUADS, DefaultVertexFormats.ITEM);
vertexbuffer.addVertexData(bakedquad.getVertexData());
if (bakedquad.hasTintIndex()) {
ClientRendererUtils.putColorRGB_F4(vertexbuffer, red * brightness, green * brightness, blue * brightness);
} else {
ClientRendererUtils.putColorRGB_F4(vertexbuffer, brightness, brightness, brightness);
}
Vec3i vec3i = bakedquad.getFace().getDirectionVec();
vertexbuffer.putNormal(vec3i.getX(), vec3i.getY(), vec3i.getZ());
tessellator.draw();
}
}
use of net.minecraft.util.math.Vec3i in project GregTech by GregTechCE.
the class MetaTileEntityTank method setTankController.
private void setTankController(MetaTileEntityTank controller) {
if (controller == this) {
return;
}
MetaTileEntityTank oldController = getControllerEntity();
if (oldController == controller) {
// do not pointlessly update controller
return;
}
if (oldController != null) {
oldController.removeTankFromMultiblock(this);
}
if (controller != null) {
// we are controlled by somebody now, remove our own controlled tanks
clearConnectedTanks();
controller.addTankToMultiblock(this);
} else {
// we are controller ourselves now
setTankControllerInternal(null);
// reset multiblock size anyway
this.multiblockSize = new Vec3i(1, 1, 1);
}
}
use of net.minecraft.util.math.Vec3i in project GregTech by GregTechCE.
the class MetaTileEntityTank method checkScanMultiblockSelf.
private void checkScanMultiblockSelf(Set<BlockPos> visitedSet) {
Map<BlockPos, MetaTileEntityTank> tankMap = findConnectedTanks(this, visitedSet);
if (tankMap.isEmpty())
return;
Comparator<BlockPos> comparator = Comparator.comparing(it -> it.getX() + it.getY() + it.getZ());
BlockPos lowestCorner = tankMap.keySet().stream().min(comparator).get();
BlockPos highestCorner = tankMap.keySet().stream().max(comparator).get();
int expectedSizeX = Math.min(highestCorner.getX() - lowestCorner.getX() + 1, maxSizeHorizontal);
int expectedSizeY = Math.min(highestCorner.getY() - lowestCorner.getY() + 1, maxSizeVertical);
int expectedSizeZ = Math.min(highestCorner.getZ() - lowestCorner.getZ() + 1, maxSizeHorizontal);
boolean multiblockAssembled = checkMultiblockValid(tankMap, lowestCorner, expectedSizeX, expectedSizeY, expectedSizeZ);
MetaTileEntityTank newController = multiblockAssembled ? tankMap.get(lowestCorner) : null;
if (newController != null) {
Vec3i multiblockSize = new Vec3i(expectedSizeX, expectedSizeY, expectedSizeZ);
newController.setTankController(null);
newController.updateControllerSize(multiblockSize);
}
tankMap.values().forEach(it -> it.setTankController(newController));
}
use of net.minecraft.util.math.Vec3i in project GregTech by GregTechCE.
the class MetaTileEntityTank method receiveCustomData.
@Override
public void receiveCustomData(int dataId, PacketBuffer buf) {
super.receiveCustomData(dataId, buf);
if (dataId == 1) {
this.controllerPos = buf.readBlockPos();
this.controllerCache = new WeakReference<>(null);
this.multiblockFluidTank.setFluid(null);
} else if (dataId == 2) {
this.controllerPos = null;
this.controllerCache = new WeakReference<>(null);
this.multiblockFluidTank.setFluid(null);
this.connectedTanks.clear();
this.multiblockSize = new Vec3i(1, 1, 1);
} else if (dataId == 3) {
if (controllerPos == null) {
FluidStack fluidStack = ByteBufUtils.readFluidStackDelta(buf, multiblockFluidTank.getFluid());
this.multiblockFluidTank.setFluid(fluidStack);
}
} else if (dataId == 4) {
this.connectedTanks = ByteBufUtils.readRelativeBlockList(buf, getPos());
this.multiblockSize = buf.readBlockPos();
recomputeTankSizeNow(true);
}
}
Aggregations