mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 07:27:15 +01:00
Schematic printing and rendering fixes
- Fix printed funnels not having filters; remove funnel survival NBT processor - Fix printed tunnels not having filters - Fix printed deployers not keeping mode - Remove boolean argument from IPartialSafeNBT.writeSafe as it was always false - Fix filters not rendering in schematic renders - Fix incorrect lighting on funnels in schematic renders - Improve rendering of crumbling overlay in ponders - Further improve CameraMixin - Use computeIfAbsent in TorquePropagator - Organize imports
This commit is contained in:
parent
999703c88b
commit
c421f98c18
23 changed files with 86 additions and 98 deletions
|
@ -26,9 +26,7 @@ public class TorquePropagator {
|
|||
public KineticNetwork getOrCreateNetworkFor(KineticTileEntity te) {
|
||||
Long id = te.network;
|
||||
KineticNetwork network;
|
||||
if (!networks.containsKey(te.getLevel()))
|
||||
networks.put(te.getLevel(), new HashMap<>());
|
||||
Map<Long, KineticNetwork> map = networks.get(te.getLevel());
|
||||
Map<Long, KineticNetwork> map = networks.computeIfAbsent(te.getLevel(), $ -> new HashMap<>());
|
||||
if (id == null)
|
||||
return null;
|
||||
|
||||
|
|
|
@ -145,8 +145,8 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeSafe(CompoundTag compound, boolean clientPacket) {
|
||||
super.writeSafe(compound, clientPacket);
|
||||
public void writeSafe(CompoundTag compound) {
|
||||
super.writeSafe(compound);
|
||||
if (input == null)
|
||||
return;
|
||||
|
||||
|
|
|
@ -403,6 +403,12 @@ public class DeployerTileEntity extends KineticTileEntity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSafe(CompoundTag tag) {
|
||||
NBTHelper.writeEnum(tag, "Mode", mode);
|
||||
super.writeSafe(tag);
|
||||
}
|
||||
|
||||
private IItemHandlerModifiable createHandler() {
|
||||
return new DeployerItemHandler(this);
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.simibubi.create.content.contraptions.components.structureMovement.ch
|
|||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.AllSoundEvents;
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.ITransformableBlock;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform;
|
||||
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.simibubi.create.content.curiosities.armor;
|
||||
|
||||
import com.simibubi.create.AllEnchantments;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.AllSoundEvents;
|
||||
import com.simibubi.create.AllTags;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
|
|
|
@ -61,8 +61,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity {
|
|||
cap.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(CompoundTag compound, boolean clientPacket) {
|
||||
protected void writeFlapsAndSides(CompoundTag compound) {
|
||||
ListTag flapsNBT = new ListTag();
|
||||
for (Direction direction : flaps.keySet())
|
||||
flapsNBT.add(IntTag.valueOf(direction.get3DDataValue()));
|
||||
|
@ -72,7 +71,17 @@ public class BeltTunnelTileEntity extends SmartTileEntity {
|
|||
for (Direction direction : sides)
|
||||
sidesNBT.add(IntTag.valueOf(direction.get3DDataValue()));
|
||||
compound.put("Sides", sidesNBT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSafe(CompoundTag tag) {
|
||||
writeFlapsAndSides(tag);
|
||||
super.writeSafe(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(CompoundTag compound, boolean clientPacket) {
|
||||
writeFlapsAndSides(compound);
|
||||
super.write(compound, clientPacket);
|
||||
}
|
||||
|
||||
|
|
|
@ -516,8 +516,8 @@ public class EjectorTileEntity extends KineticTileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeSafe(CompoundTag compound, boolean clientPacket) {
|
||||
super.writeSafe(compound, clientPacket);
|
||||
public void writeSafe(CompoundTag compound) {
|
||||
super.writeSafe(compound);
|
||||
compound.putInt("HorizontalDistance", launcher.getHorizontalDistance());
|
||||
compound.putInt("VerticalDistance", launcher.getVerticalDistance());
|
||||
}
|
||||
|
|
|
@ -124,15 +124,15 @@ public class DisplayLinkTileEntity extends SmartTileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeSafe(CompoundTag tag, boolean clientPacket) {
|
||||
super.writeSafe(tag, clientPacket);
|
||||
writeGatheredData(tag, clientPacket);
|
||||
public void writeSafe(CompoundTag tag) {
|
||||
super.writeSafe(tag);
|
||||
writeGatheredData(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void write(CompoundTag tag, boolean clientPacket) {
|
||||
super.write(tag, clientPacket);
|
||||
writeGatheredData(tag, clientPacket);
|
||||
writeGatheredData(tag);
|
||||
if (clientPacket && activeTarget != null)
|
||||
tag.putString("TargetType", activeTarget.id.toString());
|
||||
if (clientPacket && sendPulse) {
|
||||
|
@ -141,7 +141,7 @@ public class DisplayLinkTileEntity extends SmartTileEntity {
|
|||
}
|
||||
}
|
||||
|
||||
private void writeGatheredData(CompoundTag tag, boolean clientPacket) {
|
||||
private void writeGatheredData(CompoundTag tag) {
|
||||
tag.put("TargetOffset", NbtUtils.writeBlockPos(targetOffset));
|
||||
tag.putInt("TargetLine", targetLine);
|
||||
|
||||
|
|
|
@ -508,8 +508,8 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeSafe(CompoundTag compound, boolean clientPacket) {
|
||||
super.writeSafe(compound, clientPacket);
|
||||
public void writeSafe(CompoundTag compound) {
|
||||
super.writeSafe(compound);
|
||||
|
||||
writeInteractionPoints(compound);
|
||||
}
|
||||
|
|
|
@ -49,8 +49,8 @@ public class LecternControllerTileEntity extends SmartTileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeSafe(CompoundTag compound, boolean clientPacket) {
|
||||
super.writeSafe(compound, clientPacket);
|
||||
public void writeSafe(CompoundTag compound) {
|
||||
super.writeSafe(compound);
|
||||
compound.put("Controller", controller.save(new CompoundTag()));
|
||||
}
|
||||
|
||||
|
|
|
@ -159,8 +159,8 @@ public class TrackTileEntity extends SmartTileEntity implements ITransformableTE
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeSafe(CompoundTag tag, boolean clientPacket) {
|
||||
super.writeSafe(tag, clientPacket);
|
||||
public void writeSafe(CompoundTag tag) {
|
||||
super.writeSafe(tag);
|
||||
writeTurns(tag);
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ public class SchematicWorld extends WrappedWorld implements ServerLevelAccessor
|
|||
}
|
||||
return tileEntity;
|
||||
} catch (Exception e) {
|
||||
Create.LOGGER.debug("Could not create TE of block " + blockState + ": " + e);
|
||||
Create.LOGGER.debug("Could not create TE of block " + blockState, e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -738,7 +738,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
|
|||
data = NBTProcessors.process(tile, data, true);
|
||||
} else if (tile instanceof IPartialSafeNBT) {
|
||||
data = new CompoundTag();
|
||||
((IPartialSafeNBT) tile).writeSafe(data, false);
|
||||
((IPartialSafeNBT) tile).writeSafe(data);
|
||||
data = NBTProcessors.process(tile, data, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ public class SchematicRenderer {
|
|||
Random random = objects.random;
|
||||
BlockPos.MutableBlockPos mutableBlockPos = objects.mutableBlockPos;
|
||||
SchematicWorld renderWorld = schematic;
|
||||
renderWorld.renderMode = true;
|
||||
BoundingBox bounds = renderWorld.getBounds();
|
||||
|
||||
ShadeSeparatingVertexConsumer shadeSeparatingWrapper = objects.shadeSeparatingWrapper;
|
||||
|
@ -111,16 +112,16 @@ public class SchematicRenderer {
|
|||
BlockPos pos = mutableBlockPos.setWithOffset(localPos, anchor);
|
||||
BlockState state = renderWorld.getBlockState(pos);
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.translate(localPos.getX(), localPos.getY(), localPos.getZ());
|
||||
|
||||
if (state.getRenderShape() == RenderShape.MODEL && ItemBlockRenderTypes.canRenderInLayer(state, layer)) {
|
||||
BlockEntity tileEntity = renderWorld.getBlockEntity(localPos);
|
||||
dispatcher.renderBatched(state, pos, renderWorld, poseStack, shadeSeparatingWrapper, true, random,
|
||||
tileEntity != null ? tileEntity.getModelData() : EmptyModelData.INSTANCE);
|
||||
}
|
||||
poseStack.pushPose();
|
||||
poseStack.translate(localPos.getX(), localPos.getY(), localPos.getZ());
|
||||
|
||||
poseStack.popPose();
|
||||
BlockEntity tileEntity = renderWorld.getBlockEntity(localPos);
|
||||
dispatcher.renderBatched(state, pos, renderWorld, poseStack, shadeSeparatingWrapper, false, random,
|
||||
tileEntity != null ? tileEntity.getModelData() : EmptyModelData.INSTANCE);
|
||||
|
||||
poseStack.popPose();
|
||||
}
|
||||
}
|
||||
ModelBlockRenderer.clearCache();
|
||||
ForgeHooksClient.setRenderType(null);
|
||||
|
@ -130,6 +131,8 @@ public class SchematicRenderer {
|
|||
builder.appendUnshadedVertices(unshadedBuilder);
|
||||
builder.end();
|
||||
|
||||
renderWorld.renderMode = false;
|
||||
|
||||
return new SuperByteBuffer(builder);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,39 +1,22 @@
|
|||
package com.simibubi.create.foundation.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.simibubi.create.content.logistics.trains.CameraDistanceModifier;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
|
||||
@Mixin(Camera.class)
|
||||
public abstract class CameraMixin {
|
||||
|
||||
@Shadow
|
||||
private double getMaxZoom(double pStartingDistance) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@Shadow
|
||||
protected void move(double pDistanceOffset, double pVerticalOffset, double pHorizontalOffset) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ModifyArg(
|
||||
method = "Lnet/minecraft/client/Camera;setup(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/world/entity/Entity;ZZF)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;move(DDD)V", ordinal = 0),
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;getMaxZoom(D)D"),
|
||||
index = 0
|
||||
)
|
||||
public double modifyCameraOffset(double originalValue) {
|
||||
return -this.getMaxZoom(4.0D * CameraDistanceModifier.getMultiplier(AnimationTickHolder.getPartialTicks()));
|
||||
return originalValue * CameraDistanceModifier.getMultiplier(AnimationTickHolder.getPartialTicks());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -455,6 +455,10 @@ public class PonderScene {
|
|||
return basePlateSize;
|
||||
}
|
||||
|
||||
public float getScaleFactor() {
|
||||
return scaleFactor;
|
||||
}
|
||||
|
||||
public float getYOffset() {
|
||||
return yOffset;
|
||||
}
|
||||
|
@ -498,10 +502,10 @@ public class PonderScene {
|
|||
}
|
||||
|
||||
public PoseStack apply(PoseStack ms) {
|
||||
return apply(ms, AnimationTickHolder.getPartialTicks(world), false);
|
||||
return apply(ms, AnimationTickHolder.getPartialTicks(world));
|
||||
}
|
||||
|
||||
public PoseStack apply(PoseStack ms, float pt, boolean overlayCompatible) {
|
||||
public PoseStack apply(PoseStack ms, float pt) {
|
||||
ms.translate(width / 2, height / 2, 200 + offset);
|
||||
|
||||
TransformStack.cast(ms)
|
||||
|
@ -513,23 +517,11 @@ public class PonderScene {
|
|||
.rotateX(xRotation.getValue(pt))
|
||||
.rotateY(yRotation.getValue(pt));
|
||||
|
||||
UIRenderHelper.flipForGuiRender(ms);
|
||||
float f = 30 * scaleFactor;
|
||||
|
||||
if (!overlayCompatible) {
|
||||
UIRenderHelper.flipForGuiRender(ms);
|
||||
ms.scale(f, f, f);
|
||||
ms.translate((basePlateSize + basePlateOffsetX) / -2f, -1f + yOffset,
|
||||
(basePlateSize + basePlateOffsetZ) / -2f);
|
||||
} else {
|
||||
// For block breaking overlay; Don't ask
|
||||
ms.scale(f, f, f);
|
||||
if (f == 30)
|
||||
ms.translate(0.525, .2975, .9);
|
||||
ms.translate((basePlateSize + basePlateOffsetX) / -2f, -yOffset,
|
||||
(basePlateSize + basePlateOffsetZ) / -2f);
|
||||
float y = (float) (0.5065 * Math.pow(2.2975, Math.log(1 / scaleFactor) / Math.log(2))) / 30;
|
||||
ms.scale(y, -y, -y);
|
||||
}
|
||||
ms.scale(f, f, f);
|
||||
ms.translate((basePlateSize + basePlateOffsetX) / -2f, -1f + yOffset,
|
||||
(basePlateSize + basePlateOffsetZ) / -2f);
|
||||
|
||||
return ms;
|
||||
}
|
||||
|
@ -572,7 +564,7 @@ public class PonderScene {
|
|||
protected void refreshMatrix(float pt) {
|
||||
if (cachedMat != null)
|
||||
return;
|
||||
cachedMat = apply(new PoseStack(), pt, false).last()
|
||||
cachedMat = apply(new PoseStack(), pt).last()
|
||||
.pose();
|
||||
}
|
||||
|
||||
|
|
|
@ -327,23 +327,27 @@ public class WorldSectionElement extends AnimatedSceneElement {
|
|||
BlockPos pos = entry.getKey();
|
||||
if (!section.test(pos))
|
||||
continue;
|
||||
|
||||
if (overlayMS == null) {
|
||||
overlayMS = new PoseStack();
|
||||
world.scene.getTransform()
|
||||
.apply(overlayMS, pt, true);
|
||||
transformMS(overlayMS, pt);
|
||||
overlayMS.last().pose().load(ms.last().pose());
|
||||
overlayMS.last().normal().load(ms.last().normal());
|
||||
|
||||
float scaleFactor = world.scene.getScaleFactor();
|
||||
float f = (float) Math.pow(30 * scaleFactor, -1.2);
|
||||
overlayMS.scale(f, f, f);
|
||||
}
|
||||
|
||||
ms.pushPose();
|
||||
ms.translate(pos.getX(), pos.getY(), pos.getZ());
|
||||
VertexConsumer builder = new SheetedDecalTextureGenerator(
|
||||
buffer.getBuffer(ModelBakery.DESTROY_TYPES.get(entry.getValue())), overlayMS.last()
|
||||
.pose(),
|
||||
overlayMS.last()
|
||||
.normal());
|
||||
|
||||
ms.pushPose();
|
||||
ms.translate(pos.getX(), pos.getY(), pos.getZ());
|
||||
ModelUtil.VANILLA_RENDERER
|
||||
.renderBatched(world.getBlockState(pos), pos, world, ms, builder, true, new Random(),
|
||||
EmptyModelData.INSTANCE);
|
||||
.renderBreakingTexture(world.getBlockState(pos), pos, world, ms, builder, EmptyModelData.INSTANCE);
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
|
|
|
@ -453,7 +453,7 @@ public class PonderUI extends NavigatableSimiScreen {
|
|||
story.getTransform()
|
||||
.updateScreenParams(width, height, slide);
|
||||
story.getTransform()
|
||||
.apply(ms, partialTicks, false);
|
||||
.apply(ms, partialTicks);
|
||||
story.getTransform()
|
||||
.updateSceneRVE(partialTicks);
|
||||
story.renderScene(buffer, ms, partialTicks);
|
||||
|
|
|
@ -90,11 +90,11 @@ public abstract class SmartTileEntity extends CachedRenderBBTileEntity implement
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeSafe(CompoundTag tag, boolean clientPacket) {
|
||||
public void writeSafe(CompoundTag tag) {
|
||||
super.saveAdditional(tag);
|
||||
forEachBehaviour(tb -> {
|
||||
if (tb.isSafeNBT())
|
||||
tb.write(tag, clientPacket);
|
||||
tb.write(tag, false);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -95,11 +95,15 @@ public class FilteringRenderer {
|
|||
if (te == null || te.isRemoved())
|
||||
return;
|
||||
|
||||
Entity cameraEntity = Minecraft.getInstance().cameraEntity;
|
||||
float max = AllConfigs.CLIENT.filterItemRenderDistance.getF();
|
||||
if (!te.isVirtual() && cameraEntity != null && cameraEntity.position()
|
||||
.distanceToSqr(VecHelper.getCenterOf(te.getBlockPos())) > (max * max))
|
||||
return;
|
||||
if (!te.isVirtual()) {
|
||||
Entity cameraEntity = Minecraft.getInstance().cameraEntity;
|
||||
if (cameraEntity != null && te.getLevel() == cameraEntity.getLevel()) {
|
||||
float max = AllConfigs.CLIENT.filterItemRenderDistance.getF();
|
||||
if (cameraEntity.position().distanceToSqr(VecHelper.getCenterOf(te.getBlockPos())) > (max * max)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilteringBehaviour behaviour = te.getBehaviour(FilteringBehaviour.TYPE);
|
||||
if (behaviour == null)
|
||||
|
|
|
@ -272,6 +272,7 @@ public class BlockHelper {
|
|||
((KineticTileEntity) tile).warnOfMovement();
|
||||
tile.load(data);
|
||||
}
|
||||
System.out.println("");
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -3,5 +3,6 @@ package com.simibubi.create.foundation.utility;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public interface IPartialSafeNBT {
|
||||
public void writeSafe(CompoundTag compound, boolean clientPacket);
|
||||
/** This method always runs on the logical server. */
|
||||
public void writeSafe(CompoundTag compound);
|
||||
}
|
||||
|
|
|
@ -6,14 +6,10 @@ import java.util.function.UnaryOperator;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.content.logistics.item.filter.FilterItem;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
|
||||
|
@ -58,14 +54,6 @@ public final class NBTProcessors {
|
|||
}
|
||||
return data;
|
||||
});
|
||||
addSurvivalProcessor(AllTileEntities.FUNNEL.get(), data -> {
|
||||
if (data.contains("Filter")) {
|
||||
ItemStack filter = ItemStack.of(data.getCompound("Filter"));
|
||||
if (filter.getItem() instanceof FilterItem)
|
||||
data.remove("Filter");
|
||||
}
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean textComponentHasClickEvent(String json) {
|
||||
|
|
Loading…
Reference in a new issue