use of net.p3pp3rf1y.sophisticatedbackpacks.backpack.wrapper.BackpackRenderInfo in project SophisticatedBackpacks by P3pp3rF1y.
the class BackpackTileEntity method refreshRenderState.
public void refreshRenderState() {
BlockState state = getBlockState();
state = state.setValue(LEFT_TANK, false);
state = state.setValue(RIGHT_TANK, false);
BackpackRenderInfo renderInfo = backpackWrapper.getRenderInfo();
for (TankPosition pos : renderInfo.getTankRenderInfos().keySet()) {
if (pos == TankPosition.LEFT) {
state = state.setValue(LEFT_TANK, true);
} else if (pos == TankPosition.RIGHT) {
state = state.setValue(RIGHT_TANK, true);
}
}
state = state.setValue(BATTERY, renderInfo.getBatteryRenderInfo().isPresent());
level.setBlockAndUpdate(worldPosition, state);
level.updateNeighborsAt(worldPosition, state.getBlock());
WorldHelper.notifyBlockUpdate(this);
}
use of net.p3pp3rf1y.sophisticatedbackpacks.backpack.wrapper.BackpackRenderInfo in project SophisticatedBackpacks by P3pp3rF1y.
the class BackpackLayerRenderer method renderBackpack.
public static void renderBackpack(LivingEntity livingEntity, MatrixStack matrixStack, IRenderTypeBuffer buffer, int packedLight, ItemStack backpack, boolean wearsArmor) {
if (livingEntity.isCrouching()) {
matrixStack.translate(0D, 0.2D, 0D);
matrixStack.mulPose(Vector3f.XP.rotationDegrees(90F / (float) Math.PI));
}
matrixStack.mulPose(Vector3f.YP.rotationDegrees(180));
float zOffset = wearsArmor ? -0.35f : -0.3f;
float yOffset = -0.75f;
if (livingEntity.isBaby()) {
zOffset += CHILD_Z_OFFSET;
yOffset = CHILD_Y_OFFSET;
}
matrixStack.translate(0, yOffset, zOffset);
if (livingEntity.isBaby()) {
matrixStack.scale(CHILD_SCALE, CHILD_SCALE, CHILD_SCALE);
}
if (entityTranslations.containsKey(livingEntity.getType())) {
Vector3d translVector = entityTranslations.get(livingEntity.getType());
matrixStack.translate(translVector.x(), translVector.y(), translVector.z());
}
backpack.getCapability(CapabilityBackpackWrapper.getCapabilityInstance()).ifPresent(wrapper -> {
IVertexBuilder vertexBuilder = buffer.getBuffer(RenderType.entityCutoutNoCull(RenderHelper.BACKPACK_ENTITY_TEXTURE));
int clothColor = wrapper.getClothColor();
int borderColor = wrapper.getBorderColor();
Item backpackItem = backpack.getItem();
BackpackRenderInfo renderInfo = wrapper.getRenderInfo();
Set<TankPosition> tankPositions = renderInfo.getTankRenderInfos().keySet();
boolean showLeftTank = tankPositions.contains(TankPosition.LEFT);
boolean showRightTank = tankPositions.contains(TankPosition.RIGHT);
Optional<IRenderedBatteryUpgrade.BatteryRenderInfo> batteryRenderInfo = renderInfo.getBatteryRenderInfo();
MODEL.render(matrixStack, packedLight, vertexBuilder, clothColor, borderColor, backpackItem, showLeftTank, showRightTank, batteryRenderInfo.isPresent());
renderFluids(matrixStack, buffer, packedLight, renderInfo, showLeftTank, showRightTank);
batteryRenderInfo.ifPresent(info -> renderBatteryCharge(matrixStack, buffer, packedLight, info.getChargeRatio()));
renderUpgrades(livingEntity, renderInfo);
renderItemShown(matrixStack, buffer, packedLight, renderInfo);
});
}
use of net.p3pp3rf1y.sophisticatedbackpacks.backpack.wrapper.BackpackRenderInfo in project SophisticatedBackpacks by P3pp3rF1y.
the class BackpackTESR method render.
@Override
public void render(BackpackTileEntity tileEntityIn, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay) {
BlockState state = tileEntityIn.getBlockState();
Direction facing = state.getValue(BackpackBlock.FACING);
boolean showLeftTank = state.getValue(BackpackBlock.LEFT_TANK);
boolean showRightTank = state.getValue(BackpackBlock.RIGHT_TANK);
boolean showBattery = state.getValue(BackpackBlock.BATTERY);
BackpackRenderInfo renderInfo = tileEntityIn.getBackpackWrapper().getRenderInfo();
matrixStack.pushPose();
matrixStack.translate(0.5, 0, 0.5);
matrixStack.mulPose(Vector3f.YN.rotationDegrees(facing.toYRot()));
matrixStack.pushPose();
matrixStack.scale(6 / 10f, 6 / 10f, 6 / 10f);
if (showLeftTank) {
IRenderedTankUpgrade.TankRenderInfo tankRenderInfo = renderInfo.getTankRenderInfos().get(TankPosition.LEFT);
if (tankRenderInfo != null) {
tankRenderInfo.getFluid().ifPresent(fluid -> RenderHelper.renderFluid(matrixStack, buffer, combinedLight, fluid, tankRenderInfo.getFillRatio(), -12.2F, 2.5F, 0, -2F));
}
}
if (showRightTank) {
IRenderedTankUpgrade.TankRenderInfo tankRenderInfo = renderInfo.getTankRenderInfos().get(TankPosition.RIGHT);
if (tankRenderInfo != null) {
tankRenderInfo.getFluid().ifPresent(fluid -> RenderHelper.renderFluid(matrixStack, buffer, combinedLight, fluid, tankRenderInfo.getFillRatio(), 8.7F, 2.5F, 0, -2F));
}
}
matrixStack.popPose();
if (showBattery) {
renderInfo.getBatteryRenderInfo().ifPresent(batteryRenderInfo -> {
if (batteryRenderInfo.getChargeRatio() > 0.1f) {
matrixStack.pushPose();
matrixStack.mulPose(Vector3f.XN.rotationDegrees(180));
RenderHelper.renderBatteryCharge(matrixStack, buffer, combinedLight, batteryRenderInfo.getChargeRatio());
matrixStack.popPose();
}
});
}
renderItemDisplay(matrixStack, buffer, combinedLight, combinedOverlay, renderInfo);
matrixStack.popPose();
}
use of net.p3pp3rf1y.sophisticatedbackpacks.backpack.wrapper.BackpackRenderInfo in project SophisticatedBackpacks by P3pp3rF1y.
the class BackpackBlock method animateTick.
@Override
public void animateTick(BlockState state, World level, BlockPos pos, Random rand) {
WorldHelper.getTile(level, pos, BackpackTileEntity.class).ifPresent(te -> {
BackpackRenderInfo renderInfo = te.getBackpackWrapper().getRenderInfo();
renderUpgrades(level, rand, pos, state.getValue(FACING), renderInfo);
});
}
use of net.p3pp3rf1y.sophisticatedbackpacks.backpack.wrapper.BackpackRenderInfo in project SophisticatedBackpacks by P3pp3rF1y.
the class ItemDisplaySettingsCategory method updateRenderInfo.
private void updateRenderInfo() {
BackpackRenderInfo renderInfo = backpackWrapper.getRenderInfo();
if (slotIndex >= 0) {
ItemStack stackCopy = backpackWrapper.getInventoryHandler().getStackInSlot(slotIndex).copy();
stackCopy.setCount(1);
renderInfo.setItemDisplayRenderInfo(stackCopy, rotation);
} else {
renderInfo.setItemDisplayRenderInfo(ItemStack.EMPTY, 0);
}
}
Aggregations