From 0161b876fa010cea7af7b5a2a68efcc7e166e1b8 Mon Sep 17 00:00:00 2001 From: PepperCode1 <44146161+PepperCode1@users.noreply.github.com> Date: Wed, 13 Jul 2022 15:42:03 -0700 Subject: [PATCH] Foggy fixes - Use RenderFogEvent instead of FogDensity event - Adjust density of chocolate and honey fog - Fix SteamEngineBlock not setting a default state - Fix miscellaneous deprecation warnings --- .../components/steam/SteamEngineBlock.java | 5 +-- .../ContraptionCollider.java | 10 +++--- .../render/ContraptionInstanceManager.java | 2 -- .../render/FlwContraption.java | 1 - .../fluids/tank/FluidTankTileEntity.java | 2 ++ .../belt/transport/BeltMovementHandler.java | 2 +- .../source/FluidListDisplaySource.java | 2 +- .../block/vault/ItemVaultTileEntity.java | 2 ++ .../simibubi/create/events/ClientEvents.java | 34 ++++++++++--------- .../create/foundation/fluid/FluidHelper.java | 19 ++++++----- 10 files changed, 42 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/steam/SteamEngineBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/steam/SteamEngineBlock.java index 67848b7a7..e6df5d808 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/steam/SteamEngineBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/steam/SteamEngineBlock.java @@ -52,8 +52,9 @@ public class SteamEngineBlock extends FaceAttachedHorizontalDirectionalBlock private static final int placementHelperId = PlacementHelpers.register(new PlacementHelper()); - public SteamEngineBlock(Properties p_53182_) { - super(p_53182_); + public SteamEngineBlock(Properties properties) { + super(properties); + registerDefaultState(stateDefinition.any().setValue(FACE, AttachFace.FLOOR).setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, false)); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionCollider.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionCollider.java index 97c49484c..a669f66b8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionCollider.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionCollider.java @@ -175,7 +175,7 @@ public class ContraptionCollider { Vec3 collisionPosition = intersect.getCollisionPosition(); if (!isTemporal) { - Vec3 separation = intersect.asSeparationVec(entity.maxUpStep); + Vec3 separation = intersect.asSeparationVec(entity.getStepHeight()); if (separation != null && !separation.equals(Vec3.ZERO)) { collisionResponse.setValue(currentResponse.add(separation)); timeOfImpact = 0; @@ -474,12 +474,12 @@ public class ContraptionCollider { boolean flag1 = p_20273_.y != vec3.y; boolean flag2 = p_20273_.z != vec3.z; boolean flag3 = e.isOnGround() || flag1 && p_20273_.y < 0.0D; - if (e.maxUpStep > 0.0F && flag3 && (flag || flag2)) { + if (e.getStepHeight() > 0.0F && flag3 && (flag || flag2)) { Vec3 vec31 = - collideBoundingBox(e, new Vec3(p_20273_.x, (double) e.maxUpStep, p_20273_.z), aabb, e.level, list); - Vec3 vec32 = collideBoundingBox(e, new Vec3(0.0D, (double) e.maxUpStep, 0.0D), + collideBoundingBox(e, new Vec3(p_20273_.x, (double) e.getStepHeight(), p_20273_.z), aabb, e.level, list); + Vec3 vec32 = collideBoundingBox(e, new Vec3(0.0D, (double) e.getStepHeight(), 0.0D), aabb.expandTowards(p_20273_.x, 0.0D, p_20273_.z), e.level, list); - if (vec32.y < (double) e.maxUpStep) { + if (vec32.y < (double) e.getStepHeight()) { Vec3 vec33 = collideBoundingBox(e, new Vec3(p_20273_.x, 0.0D, p_20273_.z), aabb.move(vec32), e.level, list) .add(vec32); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java index df1ed3059..e23505303 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java @@ -8,8 +8,6 @@ import org.apache.commons.lang3.tuple.Pair; import com.jozufozu.flywheel.api.MaterialManager; import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.api.instance.TickableInstance; -import com.jozufozu.flywheel.backend.instancing.AbstractInstance; import com.jozufozu.flywheel.backend.instancing.TaskEngine; import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstanceManager; import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraption.java index 1149940a0..80294b087 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraption.java @@ -14,7 +14,6 @@ import com.jozufozu.flywheel.backend.instancing.batching.BatchingEngine; import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine; import com.jozufozu.flywheel.backend.model.ArrayModelRenderer; import com.jozufozu.flywheel.core.model.Model; -import com.jozufozu.flywheel.core.model.WorldModel; import com.jozufozu.flywheel.core.model.WorldModelBuilder; import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.jozufozu.flywheel.event.BeginFrameEvent; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankTileEntity.java index ea089ddc2..0ed668384 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankTileEntity.java @@ -187,6 +187,8 @@ public class FluidTankTileEntity extends SmartTileEntity implements IHaveGoggleI sendData(); } + @SuppressWarnings("unchecked") + @Override public FluidTankTileEntity getControllerTE() { if (isController()) return this; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltMovementHandler.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltMovementHandler.java index 0f2691510..2b2777af1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltMovementHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltMovementHandler.java @@ -141,7 +141,7 @@ public class BeltMovementHandler { if (!(entityIn instanceof LivingEntity) || ((LivingEntity) entityIn).zza == 0 && ((LivingEntity) entityIn).xxa == 0) movement = movement.add(centering); - + float step = entityIn.maxUpStep; if (!isPlayer) entityIn.maxUpStep = 1; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/display/source/FluidListDisplaySource.java b/src/main/java/com/simibubi/create/content/logistics/block/display/source/FluidListDisplaySource.java index 19c16a5d1..f0ef3d45f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/display/source/FluidListDisplaySource.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/display/source/FluidListDisplaySource.java @@ -59,7 +59,7 @@ public class FluidListDisplaySource extends ValueListDisplaySource { return fluids.entrySet() .stream() - .sorted((Comparator.comparingInt(value -> ((Map.Entry) value).getValue()).reversed())) + .sorted(Comparator.>comparingInt(value -> value.getValue()).reversed()) .limit(maxRows) .map(entry -> IntAttached.with( entry.getValue(), diff --git a/src/main/java/com/simibubi/create/content/logistics/block/vault/ItemVaultTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/vault/ItemVaultTileEntity.java index 402b8eaae..681bf28e8 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/vault/ItemVaultTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/vault/ItemVaultTileEntity.java @@ -112,6 +112,8 @@ public class ItemVaultTileEntity extends SmartTileEntity implements IMultiTileCo lastKnownPos = worldPosition; } + @SuppressWarnings("unchecked") + @Override public ItemVaultTileEntity getControllerTE() { if (isController()) return this; diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index 42fe5bf3c..ed9cdd809 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -314,33 +314,33 @@ public class ClientEvents { } @SubscribeEvent - public static void getFogDensity(EntityViewRenderEvent.FogDensity event) { + public static void getFogDensity(EntityViewRenderEvent.RenderFogEvent event) { Camera info = event.getCamera(); Level level = Minecraft.getInstance().level; BlockPos blockPos = info.getBlockPosition(); - FluidState fluidstate = level.getFluidState(blockPos); - if (info.getPosition().y > blockPos.getY() + fluidstate.getHeight(level, blockPos)) + FluidState fluidState = level.getFluidState(blockPos); + if (info.getPosition().y > blockPos.getY() + fluidState.getHeight(level, blockPos)) return; - Fluid fluid = fluidstate.getType(); + Fluid fluid = fluidState.getType(); if (AllFluids.CHOCOLATE.get() .isSame(fluid)) { - event.setDensity(5f); + event.scaleFarPlaneDistance(1f/32f); event.setCanceled(true); return; } if (AllFluids.HONEY.get() .isSame(fluid)) { - event.setDensity(1.5f); + event.scaleFarPlaneDistance(1f/8f); event.setCanceled(true); return; } if (FluidHelper.isWater(fluid) && AllItems.DIVING_HELMET.get() .isWornBy(Minecraft.getInstance().cameraEntity)) { - event.setDensity(300f); + event.scaleFarPlaneDistance(6.25f); event.setCanceled(true); return; } @@ -351,24 +351,26 @@ public class ClientEvents { Camera info = event.getCamera(); Level level = Minecraft.getInstance().level; BlockPos blockPos = info.getBlockPosition(); - FluidState fluidstate = level.getFluidState(blockPos); - if (info.getPosition().y > blockPos.getY() + fluidstate.getHeight(level, blockPos)) + FluidState fluidState = level.getFluidState(blockPos); + if (info.getPosition().y > blockPos.getY() + fluidState.getHeight(level, blockPos)) return; - Fluid fluid = fluidstate.getType(); + Fluid fluid = fluidState.getType(); if (AllFluids.CHOCOLATE.get() .isSame(fluid)) { - event.setRed(98 / 256f); - event.setGreen(32 / 256f); - event.setBlue(32 / 256f); + event.setRed(98 / 255f); + event.setGreen(32 / 255f); + event.setBlue(32 / 255f); + return; } if (AllFluids.HONEY.get() .isSame(fluid)) { - event.setRed(234 / 256f); - event.setGreen(174 / 256f); - event.setBlue(47 / 256f); + event.setRed(234 / 255f); + event.setGreen(174 / 255f); + event.setBlue(47 / 255f); + return; } } diff --git a/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java b/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java index ce8dec8de..be7a06a2f 100644 --- a/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java +++ b/src/main/java/com/simibubi/create/foundation/fluid/FluidHelper.java @@ -48,17 +48,18 @@ public class FluidHelper { public static boolean isLava(Fluid fluid) { return convertToStill(fluid) == Fluids.LAVA; } - - public static boolean isTag(Fluid fluid, TagKey pTag) { - return fluid.is(pTag); + + @SuppressWarnings("deprecation") + public static boolean isTag(Fluid fluid, TagKey tag) { + return fluid.is(tag); } - - public static boolean isTag(FluidState fluid, TagKey pTag) { - return isTag(fluid.getType(), pTag); + + public static boolean isTag(FluidState fluid, TagKey tag) { + return fluid.is(tag); } - - public static boolean isTag(FluidStack fluid, TagKey pTag) { - return isTag(fluid.getFluid(), pTag); + + public static boolean isTag(FluidStack fluid, TagKey tag) { + return isTag(fluid.getFluid(), tag); } public static boolean hasBlockState(Fluid fluid) {