From 03785019e9d1e05c3ed48576bf21bbb76fc312c6 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Mon, 21 Oct 2024 00:42:27 -0700 Subject: [PATCH] Remove CustomParticleManager This was used to fix a Vanilla bug where opaque particles could not show behind translucents. This has been fixed in NeoForge itself. --- .../client/fx/CustomParticleManager.java | 75 ------------------- .../render/tile/ChargingStationRenderer.java | 1 - .../client/render/tile/ClocheRenderer.java | 1 - .../metal/ChargingStationBlockEntity.java | 18 +---- .../blocks/metal/ClocheBlockEntity.java | 17 ++--- 5 files changed, 12 insertions(+), 100 deletions(-) delete mode 100644 src/main/java/blusunrize/immersiveengineering/client/fx/CustomParticleManager.java diff --git a/src/main/java/blusunrize/immersiveengineering/client/fx/CustomParticleManager.java b/src/main/java/blusunrize/immersiveengineering/client/fx/CustomParticleManager.java deleted file mode 100644 index 1f04a896e0..0000000000 --- a/src/main/java/blusunrize/immersiveengineering/client/fx/CustomParticleManager.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * BluSunrize - * Copyright (c) 2021 - * - * This code is licensed under "Blu's License of Common Sense" - * Details can be found in the license file in the root folder of this project - */ - -package blusunrize.immersiveengineering.client.fx; - -import blusunrize.immersiveengineering.client.utils.IERenderTypes; -import blusunrize.immersiveengineering.client.utils.TransformingVertexBuilder; -import blusunrize.immersiveengineering.mixin.accessors.client.ParticleManagerAccess; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.Camera; -import net.minecraft.client.Minecraft; -import net.minecraft.client.particle.Particle; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.core.particles.ParticleOptions; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -public class CustomParticleManager -{ - private final List particles = new ArrayList<>(); - - public void clientTick() - { - for(Iterator iterator = particles.iterator(); iterator.hasNext(); ) - { - Particle p = iterator.next(); - p.tick(); - if(!p.isAlive()) - iterator.remove(); - } - } - - public - void add(T particleData, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, int maxAge) - { - Particle newParticle = ((ParticleManagerAccess)Minecraft.getInstance().particleEngine).invokeMakeParticle( - particleData, x, y, z, xSpeed, ySpeed, zSpeed - ); - if(newParticle==null) - return; - if(maxAge > 0) - newParticle.setLifetime(maxAge); - particles.add(newParticle); - } - - public void render(PoseStack matrixStack, MultiBufferSource bufferIn, float partialTicks) - { - if(particles.isEmpty()) - return; - matrixStack.pushPose(); - Camera activeInfo = Minecraft.getInstance().gameRenderer.getMainCamera(); - matrixStack.translate( - activeInfo.getPosition().x, activeInfo.getPosition().y, activeInfo.getPosition().z - ); - TransformingVertexBuilder particleBuilder = new TransformingVertexBuilder( - IERenderTypes.whiteLightmap(bufferIn), IERenderTypes.PARTICLES, matrixStack - ); - // Need to fix *some* normal, so just use "up" for all quads. Does not seem to actually affect rendering. - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - particleBuilder.setDefaultNormal(0, 1, 0); - particleBuilder.setDefaultOverlay(OverlayTexture.NO_OVERLAY); - for(Particle p : particles) - p.render(particleBuilder, activeInfo, partialTicks); - matrixStack.popPose(); - } -} diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/tile/ChargingStationRenderer.java b/src/main/java/blusunrize/immersiveengineering/client/render/tile/ChargingStationRenderer.java index 723dd1ef39..bd31171c86 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/tile/ChargingStationRenderer.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/tile/ChargingStationRenderer.java @@ -23,7 +23,6 @@ public void render(ChargingStationBlockEntity te, float partialTicks, PoseStack { if(te.getLevelNonnull().hasChunkAt(te.getBlockPos())) { - te.particles.getValue().render(matrixStack, bufferIn, partialTicks); matrixStack.pushPose(); matrixStack.translate(.5, .3125, .5); matrixStack.scale(.75f, .75f, .75f); diff --git a/src/main/java/blusunrize/immersiveengineering/client/render/tile/ClocheRenderer.java b/src/main/java/blusunrize/immersiveengineering/client/render/tile/ClocheRenderer.java index 0f5464fa34..12d39e1031 100644 --- a/src/main/java/blusunrize/immersiveengineering/client/render/tile/ClocheRenderer.java +++ b/src/main/java/blusunrize/immersiveengineering/client/render/tile/ClocheRenderer.java @@ -51,7 +51,6 @@ public void render(ClocheBlockEntity tile, float partialTicks, PoseStack matrixS // Render particles in the TER rather than using the standard particle engine to avoid depth issues/the // particles not rendering at all outside of fabulous mode - tile.particles.getValue().render(matrixStack, bufferIn, partialTicks); ClocheRecipe recipe = tile.cachedRecipe.get(); if(recipe!=null) diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/ChargingStationBlockEntity.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/ChargingStationBlockEntity.java index 1a48a18d17..4d0a2216e0 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/ChargingStationBlockEntity.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/ChargingStationBlockEntity.java @@ -10,7 +10,6 @@ import blusunrize.immersiveengineering.api.IEProperties; import blusunrize.immersiveengineering.api.energy.AveragingEnergyStorage; -import blusunrize.immersiveengineering.client.fx.CustomParticleManager; import blusunrize.immersiveengineering.common.blocks.BlockCapabilityRegistration.BECapabilityRegistrar; import blusunrize.immersiveengineering.common.blocks.IEBaseBlockEntity; import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IBlockBounds; @@ -58,8 +57,6 @@ public class ChargingStationBlockEntity extends IEBaseBlockEntity implements IEC { public AveragingEnergyStorage energyStorage = new AveragingEnergyStorage(32000); public NonNullList inventory = NonNullList.withSize(1, ItemStack.EMPTY); - // Using Mutable to "hide" the reference to a client-only type behind generics type erasure - public final Mutable particles; private boolean charging = true; public int comparatorOutput = 0; private final IEnergyStorage energyCap = makeEnergyInput(energyStorage); @@ -67,16 +64,11 @@ public class ChargingStationBlockEntity extends IEBaseBlockEntity implements IEC public ChargingStationBlockEntity(BlockPos pos, BlockState state) { super(IEBlockEntities.CHARGING_STATION.get(), pos, state); - if(FMLLoader.getDist().isClient()) - this.particles = new MutableObject<>(new CustomParticleManager()); - else - this.particles = new MutableObject<>(); } @Override public void tickClient() { - particles.getValue().clientTick(); IEnergyStorage itemEnergy = inventory.get(0).getCapability(EnergyStorage.ITEM); if(itemEnergy!=null&&charging) { @@ -91,12 +83,10 @@ public void tickClient() if(charge >= 1||(time%12 >= i*4&&time%12 <= i*4+2)) { int shift = i-1; - double x = .5+(getFacing()==Direction.WEST?-.46875: getFacing()==Direction.EAST?.46875: getFacing()==Direction.NORTH?(-.1875*shift): (.1875*shift)); - double y = .25; - double z = .5+(getFacing()==Direction.NORTH?-.46875: getFacing()==Direction.SOUTH?.46875: getFacing()==Direction.EAST?(-.1875*shift): (.1875*shift)); - particles.getValue().add( - new DustParticleOptions(new Vector3f(1-charge, charge, 0), .5f), x, y, z, .25, .25, .25, -1 - ); + double x = getBlockPos().getX()+.5+(getFacing()==Direction.WEST?-.46875: getFacing()==Direction.EAST?.46875: getFacing()==Direction.NORTH?(-.1875*shift): (.1875*shift)); + double y = getBlockPos().getY()+.25; + double z = getBlockPos().getZ()+.5+(getFacing()==Direction.NORTH?-.46875: getFacing()==Direction.SOUTH?.46875: getFacing()==Direction.EAST?(-.1875*shift): (.1875*shift)); + level.addParticle(new DustParticleOptions(new Vector3f(1-charge, charge, 0), .5f), x, y, z, .25, .25, .25); } } } diff --git a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/ClocheBlockEntity.java b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/ClocheBlockEntity.java index 0abba63a45..3ab4a97630 100644 --- a/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/ClocheBlockEntity.java +++ b/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/ClocheBlockEntity.java @@ -15,7 +15,6 @@ import blusunrize.immersiveengineering.api.crafting.ClocheRecipe; import blusunrize.immersiveengineering.api.crafting.TagOutputList; import blusunrize.immersiveengineering.api.energy.MutableEnergyStorage; -import blusunrize.immersiveengineering.client.fx.CustomParticleManager; import blusunrize.immersiveengineering.common.blocks.BlockCapabilityRegistration.BECapabilityRegistrar; import blusunrize.immersiveengineering.common.blocks.IEBaseBlockEntity; import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IHasDummyBlocks; @@ -33,6 +32,9 @@ import blusunrize.immersiveengineering.common.util.IEBlockCapabilityCaches.IEBlockCapabilityCache; import blusunrize.immersiveengineering.common.util.inventory.IEInventoryHandler; import blusunrize.immersiveengineering.common.util.inventory.IIEInventory; +import blusunrize.immersiveengineering.mixin.accessors.client.ParticleManagerAccess; +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.Particle; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.HolderLookup.Provider; @@ -100,8 +102,6 @@ public boolean isFluidValid(FluidStack fluid) public MutableEnergyStorage energyStorage = new MutableEnergyStorage( ENERGY_CAPACITY, Math.max(256, getOrDefault(IEServerConfig.MACHINES.cloche_consumption)) ); - // Using Mutable to "hide" the reference to a client-only type behind generics type erasure - public final Mutable particles; public final Supplier cachedRecipe = CachedRecipe.cached( ClocheRecipe::findRecipe, () -> level, () -> inventory.get(SLOT_SEED), () -> inventory.get(SLOT_SOIL) ); @@ -122,10 +122,6 @@ public boolean isFluidValid(FluidStack fluid) public ClocheBlockEntity(BlockEntityType type, BlockPos pos, BlockState state) { super(type, pos, state); - if(FMLLoader.getDist().isClient()) - this.particles = new MutableObject<>(new CustomParticleManager()); - else - this.particles = new MutableObject<>(); } @Override @@ -137,7 +133,6 @@ public boolean canTickAny() @Override public void tickClient() { - particles.getValue().clientTick(); ItemStack seed = inventory.get(SLOT_SEED); ItemStack soil = inventory.get(SLOT_SOIL); if(renderActive) @@ -151,7 +146,11 @@ public void tickClient() else renderGrowth = 0; if(ApiUtils.RANDOM.nextInt(8)==0) - particles.getValue().add(new DustParticleOptions(new Vector3f(.55f, .1f, .1f), 1), .5, 2.6875, .5, .25, .25, .25, 20); + { + Particle p = ((ParticleManagerAccess)Minecraft.getInstance().particleEngine).invokeMakeParticle(new DustParticleOptions(new Vector3f(.55f, .1f, .1f), 1), getBlockPos().getX() + .5, getBlockPos().getY() + 2.6875, getBlockPos().getZ() + .5, .25, .25, .25); + p.setLifetime(20); + Minecraft.getInstance().particleEngine.add(p); + } } } }