mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-15 23:56:14 +01:00
Merge branch 'Creators-of-Create:mc1.16/dev' into mc1.16/interaction
This commit is contained in:
commit
c6db66876a
10 changed files with 56 additions and 19 deletions
|
@ -7,6 +7,7 @@ import java.util.function.Function;
|
||||||
|
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
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.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.contraptions.relays.encased.CasingConnectivity;
|
||||||
import com.simibubi.create.content.curiosities.armor.CopperBacktankArmorLayer;
|
import com.simibubi.create.content.curiosities.armor.CopperBacktankArmorLayer;
|
||||||
import com.simibubi.create.content.curiosities.bell.SoulPulseEffectHandler;
|
import com.simibubi.create.content.curiosities.bell.SoulPulseEffectHandler;
|
||||||
|
@ -94,7 +95,7 @@ public class CreateClient {
|
||||||
|
|
||||||
public static void clientInit(FMLClientSetupEvent event) {
|
public static void clientInit(FMLClientSetupEvent event) {
|
||||||
BUFFER_CACHE.registerCompartment(KineticTileEntityRenderer.KINETIC_TILE);
|
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);
|
BUFFER_CACHE.registerCompartment(WorldSectionElement.DOC_WORLD_SECTION, 20);
|
||||||
|
|
||||||
AllKeys.register();
|
AllKeys.register();
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Optional;
|
||||||
|
|
||||||
import com.simibubi.create.AllRecipeTypes;
|
import com.simibubi.create.AllRecipeTypes;
|
||||||
import com.simibubi.create.AllSoundEvents;
|
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.FluidFX;
|
||||||
import com.simibubi.create.content.contraptions.fluids.recipe.PotionMixingRecipeManager;
|
import com.simibubi.create.content.contraptions.fluids.recipe.PotionMixingRecipeManager;
|
||||||
import com.simibubi.create.content.contraptions.processing.BasinOperatingTileEntity;
|
import com.simibubi.create.content.contraptions.processing.BasinOperatingTileEntity;
|
||||||
|
@ -229,8 +230,8 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity {
|
||||||
protected <C extends IInventory> boolean matchStaticFilters(IRecipe<C> r) {
|
protected <C extends IInventory> boolean matchStaticFilters(IRecipe<C> r) {
|
||||||
return ((r.getSerializer() == IRecipeSerializer.SHAPELESS_RECIPE
|
return ((r.getSerializer() == IRecipeSerializer.SHAPELESS_RECIPE
|
||||||
&& AllConfigs.SERVER.recipes.allowShapelessInMixer.get() && r.getIngredients()
|
&& AllConfigs.SERVER.recipes.allowShapelessInMixer.get() && r.getIngredients()
|
||||||
.size() > 1)
|
.size() > 1
|
||||||
|| r.getType() == AllRecipeTypes.MIXING.getType());
|
&& !MechanicalPressTileEntity.canCompress(r)) || r.getType() == AllRecipeTypes.MIXING.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -44,7 +44,16 @@ public class ContraptionRenderDispatcher {
|
||||||
|
|
||||||
private static WorldAttached<ContraptionRenderManager<?>> WORLDS = new WorldAttached<>(SBBContraptionManager::new);
|
private static WorldAttached<ContraptionRenderManager<?>> WORLDS = new WorldAttached<>(SBBContraptionManager::new);
|
||||||
|
|
||||||
public static final Compartment<Pair<Contraption, RenderType>> 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) {
|
public static void tick(World world) {
|
||||||
if (Minecraft.getInstance().isPaused()) return;
|
if (Minecraft.getInstance().isPaused()) return;
|
||||||
|
|
|
@ -68,4 +68,8 @@ public class ContraptionRenderInfo {
|
||||||
public ContraptionMatrices getMatrices() {
|
public ContraptionMatrices getMatrices() {
|
||||||
return matrices;
|
return matrices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void invalidate() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,20 @@ public abstract class ContraptionRenderManager<C extends ContraptionRenderInfo>
|
||||||
this.world = (World) world;
|
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) {
|
public void renderLayer(RenderLayerEvent event) {
|
||||||
for (C c : visible) {
|
for (C c : visible) {
|
||||||
c.setupMatrices(event.stack, event.camX, event.camY, event.camZ);
|
c.setupMatrices(event.stack, event.camX, event.camY, event.camZ);
|
||||||
|
@ -85,6 +99,9 @@ public abstract class ContraptionRenderManager<C extends ContraptionRenderInfo>
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
|
for (C renderer : renderInfos.values()) {
|
||||||
|
renderer.invalidate();
|
||||||
|
}
|
||||||
renderInfos.clear();
|
renderInfos.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,12 +94,4 @@ public class FlwContraptionManager extends ContraptionRenderManager<RenderedCont
|
||||||
// we use visible in #tick() so we have to re-evaluate it if any were removed
|
// we use visible in #tick() so we have to re-evaluate it if any were removed
|
||||||
if (removed) collectVisible();
|
if (removed) collectVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete() {
|
|
||||||
for (RenderedContraption renderer : renderInfos.values()) {
|
|
||||||
renderer.invalidate();
|
|
||||||
}
|
|
||||||
renderInfos.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class RenderedContraption extends ContraptionRenderInfo {
|
||||||
lighter.lightVolume.bind();
|
lighter.lightVolume.bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
void invalidate() {
|
public void invalidate() {
|
||||||
for (ModelRenderer buffer : renderLayers.values()) {
|
for (ModelRenderer buffer : renderLayers.values()) {
|
||||||
buffer.delete();
|
buffer.delete();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,21 @@
|
||||||
package com.simibubi.create.content.contraptions.components.structureMovement.render;
|
package com.simibubi.create.content.contraptions.components.structureMovement.render;
|
||||||
|
|
||||||
import static com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher.CONTRAPTION;
|
|
||||||
import static com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher.buildStructureBuffer;
|
import static com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher.buildStructureBuffer;
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
|
|
||||||
import com.jozufozu.flywheel.event.RenderLayerEvent;
|
import com.jozufozu.flywheel.event.RenderLayerEvent;
|
||||||
import com.simibubi.create.CreateClient;
|
import com.simibubi.create.CreateClient;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
|
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
|
||||||
|
import com.simibubi.create.foundation.render.Compartment;
|
||||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||||
|
import com.simibubi.create.foundation.utility.Pair;
|
||||||
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
|
|
||||||
public class SBBContraptionManager extends ContraptionRenderManager<ContraptionRenderInfo> {
|
public class SBBContraptionManager extends ContraptionRenderManager<ContraptionRenderInfo> {
|
||||||
|
public static final Compartment<Pair<Contraption, RenderType>> CONTRAPTION = new Compartment<>();
|
||||||
|
|
||||||
public SBBContraptionManager(IWorld world) {
|
public SBBContraptionManager(IWorld world) {
|
||||||
super(world);
|
super(world);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +26,14 @@ public class SBBContraptionManager extends ContraptionRenderManager<ContraptionR
|
||||||
visible.forEach(info -> renderContraptionLayerSBB(event, info));
|
visible.forEach(info -> 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
|
@Override
|
||||||
protected ContraptionRenderInfo create(Contraption c) {
|
protected ContraptionRenderInfo create(Contraption c) {
|
||||||
PlacementSimulationWorld renderWorld = ContraptionRenderDispatcher.setupRenderWorld(world, c);
|
PlacementSimulationWorld renderWorld = ContraptionRenderDispatcher.setupRenderWorld(world, c);
|
||||||
|
|
|
@ -77,9 +77,9 @@ public class AirParticle extends SimpleAnimatedParticle {
|
||||||
float y = (float) (MathHelper.lerp(progress, originY, targetY) + twirl.y);
|
float y = (float) (MathHelper.lerp(progress, originY, targetY) + twirl.y);
|
||||||
float z = (float) (MathHelper.lerp(progress, originZ, targetZ) + twirl.z);
|
float z = (float) (MathHelper.lerp(progress, originZ, targetZ) + twirl.z);
|
||||||
|
|
||||||
xd = x - x;
|
xd = x - this.x;
|
||||||
yd = y - y;
|
yd = y - this.y;
|
||||||
zd = z - z;
|
zd = z - this.z;
|
||||||
|
|
||||||
setSpriteFromAge(sprites);
|
setSpriteFromAge(sprites);
|
||||||
this.move(this.xd, this.yd, this.zd);
|
this.move(this.xd, this.yd, this.zd);
|
||||||
|
|
|
@ -178,5 +178,9 @@ public abstract class AbstractSimiScreen extends Screen {
|
||||||
protected void debugWindowArea(MatrixStack matrixStack) {
|
protected void debugWindowArea(MatrixStack matrixStack) {
|
||||||
fill(matrixStack, guiLeft + windowWidth, guiTop + windowHeight, guiLeft, guiTop, 0xD3D3D3D3);
|
fill(matrixStack, guiLeft + windowWidth, guiTop + windowHeight, guiLeft, guiTop, 0xD3D3D3D3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Widget> getWidgets() {
|
||||||
|
return widgets;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue