diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index 52bfb4fe8..88c5b0194 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -7,6 +7,7 @@ import java.util.function.Function; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; +import com.simibubi.create.content.contraptions.components.structureMovement.render.SBBContraptionManager; import com.simibubi.create.content.contraptions.relays.encased.CasingConnectivity; import com.simibubi.create.content.curiosities.armor.CopperBacktankArmorLayer; import com.simibubi.create.content.curiosities.bell.SoulPulseEffectHandler; @@ -94,7 +95,7 @@ public class CreateClient { public static void clientInit(FMLClientSetupEvent event) { BUFFER_CACHE.registerCompartment(KineticTileEntityRenderer.KINETIC_TILE); - BUFFER_CACHE.registerCompartment(ContraptionRenderDispatcher.CONTRAPTION, 20); + BUFFER_CACHE.registerCompartment(SBBContraptionManager.CONTRAPTION, 20); BUFFER_CACHE.registerCompartment(WorldSectionElement.DOC_WORLD_SECTION, 20); AllKeys.register(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerTileEntity.java index 67808f292..1d7bd0db7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerTileEntity.java @@ -5,6 +5,7 @@ import java.util.Optional; import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.AllSoundEvents; +import com.simibubi.create.content.contraptions.components.press.MechanicalPressTileEntity; import com.simibubi.create.content.contraptions.fluids.FluidFX; import com.simibubi.create.content.contraptions.fluids.recipe.PotionMixingRecipeManager; import com.simibubi.create.content.contraptions.processing.BasinOperatingTileEntity; @@ -229,8 +230,8 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity { protected boolean matchStaticFilters(IRecipe r) { return ((r.getSerializer() == IRecipeSerializer.SHAPELESS_RECIPE && AllConfigs.SERVER.recipes.allowShapelessInMixer.get() && r.getIngredients() - .size() > 1) - || r.getType() == AllRecipeTypes.MIXING.getType()); + .size() > 1 + && !MechanicalPressTileEntity.canCompress(r)) || r.getType() == AllRecipeTypes.MIXING.getType()); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index f74968039..98e5e9fbb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -44,7 +44,16 @@ public class ContraptionRenderDispatcher { private static WorldAttached> WORLDS = new WorldAttached<>(SBBContraptionManager::new); - public static final Compartment> CONTRAPTION = new Compartment<>(); + /** + * Reset a contraption's renderer. + * @param contraption The contraption to invalidate. + * @return true if there was a renderer associated with the given contraption. + */ + public static boolean invalidate(Contraption contraption) { + World level = contraption.entity.level; + + return WORLDS.get(level).invalidate(contraption); + } public static void tick(World world) { if (Minecraft.getInstance().isPaused()) return; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderInfo.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderInfo.java index 2b628393e..861db5c41 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderInfo.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderInfo.java @@ -68,4 +68,8 @@ public class ContraptionRenderInfo { public ContraptionMatrices getMatrices() { return matrices; } + + public void invalidate() { + + } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderManager.java index 735d569f1..5bc3abed3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderManager.java @@ -29,6 +29,20 @@ public abstract class ContraptionRenderManager this.world = (World) world; } + public boolean invalidate(Contraption contraption) { + int entityId = contraption.entity.getId(); + + C removed = renderInfos.remove(entityId); + + if (removed != null) { + removed.invalidate(); + visible.remove(removed); + return true; + } + + return false; + } + public void renderLayer(RenderLayerEvent event) { for (C c : visible) { c.setupMatrices(event.stack, event.camX, event.camY, event.camZ); @@ -85,6 +99,9 @@ public abstract class ContraptionRenderManager } public void delete() { + for (C renderer : renderInfos.values()) { + renderer.invalidate(); + } renderInfos.clear(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java index efd42ad70..05485d3ad 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java @@ -94,12 +94,4 @@ public class FlwContraptionManager extends ContraptionRenderManager { + public static final Compartment> CONTRAPTION = new Compartment<>(); + public SBBContraptionManager(IWorld world) { super(world); } @@ -25,6 +26,14 @@ public class SBBContraptionManager extends ContraptionRenderManager renderContraptionLayerSBB(event, info)); } + @Override + public boolean invalidate(Contraption contraption) { + for (RenderType chunkBufferLayer : RenderType.chunkBufferLayers()) { + CreateClient.BUFFER_CACHE.invalidate(CONTRAPTION, Pair.of(contraption, chunkBufferLayer)); + } + return super.invalidate(contraption); + } + @Override protected ContraptionRenderInfo create(Contraption c) { PlacementSimulationWorld renderWorld = ContraptionRenderDispatcher.setupRenderWorld(world, c); diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/AirParticle.java b/src/main/java/com/simibubi/create/content/contraptions/particle/AirParticle.java index 25d7d9f02..1951cdedb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/AirParticle.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/AirParticle.java @@ -77,9 +77,9 @@ public class AirParticle extends SimpleAnimatedParticle { float y = (float) (MathHelper.lerp(progress, originY, targetY) + twirl.y); float z = (float) (MathHelper.lerp(progress, originZ, targetZ) + twirl.z); - xd = x - x; - yd = y - y; - zd = z - z; + xd = x - this.x; + yd = y - this.y; + zd = z - this.z; setSpriteFromAge(sprites); this.move(this.xd, this.yd, this.zd); diff --git a/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java b/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java index 1329ee837..84689cf0b 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java @@ -178,5 +178,9 @@ public abstract class AbstractSimiScreen extends Screen { protected void debugWindowArea(MatrixStack matrixStack) { fill(matrixStack, guiLeft + windowWidth, guiTop + windowHeight, guiLeft, guiTop, 0xD3D3D3D3); } + + public List getWidgets() { + return widgets; + } }