Fix obvious errors

This commit is contained in:
grimmauld 2021-09-15 09:26:51 +02:00
parent 2fc54ffbee
commit 0b2101c25d
39 changed files with 101 additions and 92 deletions

View file

@ -1,8 +1,5 @@
package com.jozufozu.flywheel.backend; package com.jozufozu.flywheel.backend;
import java.util.Collection;
import java.util.function.Predicate;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
@ -21,23 +18,27 @@ import com.mojang.serialization.JsonOps;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ReloadableResourceManager; import net.minecraft.server.packs.resources.ReloadableResourceManager;
import net.minecraft.server.packs.resources.Resource; import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
import net.minecraftforge.fml.ModLoader; import net.minecraftforge.fml.ModLoader;
import net.minecraftforge.resource.IResourceType; import net.minecraftforge.resource.IResourceType;
import net.minecraftforge.resource.ISelectiveResourceReloadListener;
import net.minecraftforge.resource.VanillaResourceType; import net.minecraftforge.resource.VanillaResourceType;
import javax.annotation.Nullable;
import java.util.Collection;
/** /**
* The main entity for loading shaders. * The main entity for loading shaders.
* *
* <p> * <p>
* This class is responsible for invoking the loading, parsing, and compilation stages. * This class is responsible for invoking the loading, parsing, and compilation stages.
* </p> * </p>
*/ */
public class Loader implements ISelectiveResourceReloadListener { public class Loader implements ResourceManagerReloadListener {
public static final String PROGRAM_DIR = "flywheel/programs/"; public static final String PROGRAM_DIR = "flywheel/programs/";
private static final Gson GSON = new GsonBuilder().create(); private static final Gson GSON = new GsonBuilder().create();
@ -64,44 +65,42 @@ public class Loader implements ISelectiveResourceReloadListener {
} }
@Override @Override
public void onResourceManagerReload(ResourceManager manager, Predicate<IResourceType> predicate) { public void onResourceManagerReload(ResourceManager manager) {
if (predicate.test(VanillaResourceType.SHADERS)) { backend.refresh();
backend.refresh();
if (backend.gl20()) { if (backend.gl20()) {
shouldCrash = false; shouldCrash = false;
backend._clearContexts(); backend._clearContexts();
Resolver.INSTANCE.invalidate(); Resolver.INSTANCE.invalidate();
ModLoader.get() ModLoader.get()
.postEvent(new GatherContextEvent(backend, firstLoad)); .postEvent(new GatherContextEvent(backend, firstLoad));
ShaderSources sources = new ShaderSources(manager); ShaderSources sources = new ShaderSources(manager);
loadProgramSpecs(manager); loadProgramSpecs(manager);
Resolver.INSTANCE.resolve(sources); Resolver.INSTANCE.resolve(sources);
for (IShaderContext<?> context : backend.allContexts()) { for (IShaderContext<?> context : backend.allContexts()) {
context.load(); context.load();
}
if (shouldCrash) {
throw new ShaderLoadingException("Could not load all shaders, see log for details");
}
Backend.log.info("Loaded all shader programs.");
ClientLevel world = Minecraft.getInstance().level;
if (Backend.isFlywheelWorld(world)) {
// TODO: looks like it might be good to have another event here
InstancedRenderDispatcher.loadAllInWorld(world);
CrumblingRenderer.reset();
}
} }
firstLoad = false; if (shouldCrash) {
throw new ShaderLoadingException("Could not load all shaders, see log for details");
}
Backend.log.info("Loaded all shader programs.");
ClientLevel world = Minecraft.getInstance().level;
if (Backend.isFlywheelWorld(world)) {
// TODO: looks like it might be good to have another event here
InstancedRenderDispatcher.loadAllInWorld(world);
CrumblingRenderer.reset();
}
} }
firstLoad = false;
} }
private void loadProgramSpecs(ResourceManager manager) { private void loadProgramSpecs(ResourceManager manager) {
@ -129,4 +128,10 @@ public class Loader implements ISelectiveResourceReloadListener {
} }
} }
} }
@Nullable
@Override
public IResourceType getResourceType() {
return VanillaResourceType.SHADERS;
}
} }

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.backend.gl.attrib;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.backend.gl.buffer;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.backend.gl;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.backend.gl.shader;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -3,7 +3,7 @@ package com.jozufozu.flywheel.backend.instancing;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
/** /**
* Something (a TileEntity or Entity) that can be rendered using the instancing API. * Something (a BlockEntity or Entity) that can be rendered using the instancing API.
*/ */
public interface IInstanceRendered { public interface IInstanceRendered {

View file

@ -13,7 +13,7 @@ import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
* eg. adding or removing parts, snapping to a different rotation, etc. * eg. adding or removing parts, snapping to a different rotation, etc.
* </li> * </li>
* <li> * <li>
* Your TileEntity does animate, but the animation doesn't have * Your BlockEntity does animate, but the animation doesn't have
* to be smooth, in which case this could be an optimization. * to be smooth, in which case this could be an optimization.
* </li> * </li>
* </ul> * </ul>

View file

@ -11,7 +11,7 @@ import com.jozufozu.flywheel.light.IMovingListener;
import com.jozufozu.flywheel.light.LightProvider; import com.jozufozu.flywheel.light.LightProvider;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.tileentity.TileEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -20,7 +20,7 @@ import com.mojang.math.Vector3f;
import net.minecraft.core.Vec3i; import net.minecraft.core.Vec3i;
/** /**
* The layer between a {@link TileEntity} and the Flywheel backend. * The layer between a {@link BlockEntity} and the Flywheel backend.
* * * *
* <br><br> There are a few additional features that overriding classes can opt in to: * <br><br> There are a few additional features that overriding classes can opt in to:
* <ul> * <ul>

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.backend.instancing.entity;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.backend.instancing;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -16,7 +16,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
/** /**
* The layer between a {@link TileEntity} and the Flywheel backend. * The layer between a {@link BlockEntity} and the Flywheel backend.
* *
* <br><br> {@link #updateLight()} is called after construction. * <br><br> {@link #updateLight()} is called after construction.
* *
@ -30,7 +30,7 @@ import net.minecraft.core.BlockPos;
* <br> Implementing one or more of these will give a {@link TileEntityInstance} access * <br> Implementing one or more of these will give a {@link TileEntityInstance} access
* to more interesting and regular points within a tick or a frame. * to more interesting and regular points within a tick or a frame.
* *
* @param <T> The type of {@link TileEntity} your class is an instance of. * @param <T> The type of {@link BlockEntity} your class is an instance of.
*/ */
public abstract class TileEntityInstance<T extends BlockEntity> extends AbstractInstance { public abstract class TileEntityInstance<T extends BlockEntity> extends AbstractInstance {
@ -64,7 +64,7 @@ public abstract class TileEntityInstance<T extends BlockEntity> extends Abstract
* {@link TileInstanceManager}s are allowed to arbitrarily adjust the origin, and * {@link TileInstanceManager}s are allowed to arbitrarily adjust the origin, and
* shift the world matrix provided as a shader uniform accordingly. * shift the world matrix provided as a shader uniform accordingly.
* *
* @return The {@link BlockPos position} of the {@link TileEntity} this instance * @return The {@link BlockPos position} of the {@link BlockEntity} this instance
* represents should be rendered at to appear in the correct location. * represents should be rendered at to appear in the correct location.
*/ */
public BlockPos getInstancePosition() { public BlockPos getInstancePosition() {

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.backend.instancing.tile;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.backend.material;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.backend;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.backend.pipeline;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.backend.source.error;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.backend.source;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -4,4 +4,4 @@ package com.jozufozu.flywheel.backend.source.parse;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.backend.source.span;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -34,7 +34,7 @@ public class TextureRenderState implements IRenderState {
@Override @Override
public void bind() { public void bind() {
unit.makeActive(); unit.makeActive();
Minecraft.getInstance().textureManager.bind(location); Minecraft.getInstance().textureManager.bindForSetup(location);
} }
@Override @Override

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.backend.state;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -6,7 +6,7 @@ import com.mojang.brigadier.builder.ArgumentBuilder;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands; import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.fml.network.PacketDistributor; import net.minecraftforge.fmllegacy.network.PacketDistributor;
public class BooleanConfigCommand { public class BooleanConfigCommand {

View file

@ -5,7 +5,7 @@ import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands; import net.minecraft.commands.Commands;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent; import net.minecraftforge.fmlserverevents.FMLServerStartingEvent;
public class FlwCommands { public class FlwCommands {
@SubscribeEvent @SubscribeEvent

View file

@ -3,9 +3,9 @@ package com.jozufozu.flywheel.config;
import com.jozufozu.flywheel.Flywheel; import com.jozufozu.flywheel.Flywheel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.fml.network.NetworkDirection; import net.minecraftforge.fmllegacy.network.NetworkDirection;
import net.minecraftforge.fml.network.NetworkRegistry; import net.minecraftforge.fmllegacy.network.NetworkRegistry;
import net.minecraftforge.fml.network.simple.SimpleChannel; import net.minecraftforge.fmllegacy.network.simple.SimpleChannel;
public class FlwPackets { public class FlwPackets {
public static final ResourceLocation CHANNEL_NAME = new ResourceLocation(Flywheel.ID, "network"); public static final ResourceLocation CHANNEL_NAME = new ResourceLocation(Flywheel.ID, "network");

View file

@ -1,9 +1,10 @@
package com.jozufozu.flywheel.config; package com.jozufozu.flywheel.config;
import java.util.function.Supplier;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.fmllegacy.network.NetworkEvent;
import java.util.function.Supplier;
/** /**
* Thanks, @zelophed * Thanks, @zelophed

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.core.crumbling;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -6,7 +6,6 @@ import com.jozufozu.flywheel.util.vec.Vec3;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import com.mojang.math.Quaternion; import com.mojang.math.Quaternion;
import net.minecraft.world.phys.Vec3;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
public class OrientedData extends BasicData { public class OrientedData extends BasicData {
@ -55,7 +54,7 @@ public class OrientedData extends BasicData {
return setPosition(pos.x(), pos.y(), pos.z()); return setPosition(pos.x(), pos.y(), pos.z());
} }
public OrientedData setPivot(Vec3 pos) { public OrientedData setPivot(net.minecraft.world.phys.Vec3 pos) {
return setPosition((float) pos.x(), (float) pos.y(), (float) pos.z()); return setPosition((float) pos.x(), (float) pos.y(), (float) pos.z());
} }

View file

@ -81,8 +81,8 @@ public class BlockModel implements IModel {
// .flatMap(dir -> model.getQuads(referenceState, dir, mc.world.rand, modelData).stream()) // .flatMap(dir -> model.getQuads(referenceState, dir, mc.world.rand, modelData).stream())
// .collect(Collectors.toList()); // .collect(Collectors.toList());
builder.begin(GL11.GL_QUADS, DefaultVertexFormat.BLOCK); builder.begin(com.mojang.blaze3d.vertex.VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK);
blockRenderer.renderModel(mc.level, model, referenceState, BlockPos.ZERO.above(255), ms, builder, true, mc.level.random, 42, OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE); blockRenderer.tesselateBlock(mc.level, model, referenceState, BlockPos.ZERO.above(255), ms, builder, true, mc.level.random, 42, OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE);
builder.end(); builder.end();
return builder; return builder;
} }

View file

@ -1,5 +1,6 @@
package com.jozufozu.flywheel.core.model; package com.jozufozu.flywheel.core.model;
import static com.mojang.blaze3d.vertex.VertexFormat.Mode.QUADS;
import static org.lwjgl.opengl.GL11.GL_QUADS; import static org.lwjgl.opengl.GL11.GL_QUADS;
import java.util.Collection; import java.util.Collection;
@ -32,7 +33,7 @@ public class ModelUtil {
PoseStack ms = new PoseStack(); PoseStack ms = new PoseStack();
Random random = new Random(); Random random = new Random();
BufferBuilder builder = new BufferBuilder(DefaultVertexFormat.BLOCK.getIntegerSize()); BufferBuilder builder = new BufferBuilder(DefaultVertexFormat.BLOCK.getIntegerSize());
builder.begin(GL_QUADS, DefaultVertexFormat.BLOCK); builder.begin(QUADS, DefaultVertexFormat.BLOCK);
ForgeHooksClient.setRenderLayer(layer); ForgeHooksClient.setRenderLayer(layer);
ModelBlockRenderer.enableCaching(); ModelBlockRenderer.enableCaching();
@ -48,7 +49,7 @@ public class ModelUtil {
ms.pushPose(); ms.pushPose();
ms.translate(pos.getX(), pos.getY(), pos.getZ()); ms.translate(pos.getX(), pos.getY(), pos.getZ());
MODEL_RENDERER.get().renderModel(renderWorld, BLOCK_MODELS.get().getBlockModel(state), state, pos, ms, builder, true, MODEL_RENDERER.get().tesselateBlock(renderWorld, BLOCK_MODELS.get().getBlockModel(state), state, pos, ms, builder, true,
random, 42, OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE); random, 42, OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE);
ms.popPose(); ms.popPose();
} }

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.core.model;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.core;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -3,7 +3,7 @@ package com.jozufozu.flywheel.event;
import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.Backend;
import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.event.lifecycle.IModBusEvent; import net.minecraftforge.fml.event.IModBusEvent;
public class GatherContextEvent extends Event implements IModBusEvent { public class GatherContextEvent extends Event implements IModBusEvent {

View file

@ -3,4 +3,4 @@ package com.jozufozu.flywheel.event;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault; import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -21,7 +21,7 @@ import net.minecraft.util.ClassInstanceMultiMap;
public class CancelEntityRenderMixin { public class CancelEntityRenderMixin {
@Group(name = "entityFilter", min = 1, max = 1) @Group(name = "entityFilter", min = 1, max = 1)
@Redirect(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;entitiesForRendering()Ljava/lang/Iterable;")) @Redirect(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;entitiesForRendering()Ljava/lang/Iterable;"))
private Iterable<Entity> filterEntities(ClientLevel world) { private Iterable<Entity> filterEntities(ClientLevel world) {
Iterable<Entity> entities = world.entitiesForRendering(); Iterable<Entity> entities = world.entitiesForRendering();
if (Backend.getInstance() if (Backend.getInstance()
@ -38,7 +38,7 @@ public class CancelEntityRenderMixin {
} }
@Group(name = "entityFilter") @Group(name = "entityFilter")
@Redirect(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ClassInheritanceMultiMap;iterator()Ljava/util/Iterator;")) @Redirect(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ClassInstanceMultiMap;iterator()Ljava/util/Iterator;"))
private Iterator<Entity> filterEntitiesOF(ClassInstanceMultiMap<Entity> classInheritanceMultiMap) { private Iterator<Entity> filterEntitiesOF(ClassInstanceMultiMap<Entity> classInheritanceMultiMap) {
if (Backend.getInstance() if (Backend.getInstance()
.canUseInstancing()) { .canUseInstancing()) {

View file

@ -22,6 +22,8 @@ import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkAccess;
import java.util.BitSet;
@Mixin(ClientChunkCache.class) @Mixin(ClientChunkCache.class)
public abstract class FastChunkProviderMixin extends ChunkSource { public abstract class FastChunkProviderMixin extends ChunkSource {
@ -71,7 +73,7 @@ public abstract class FastChunkProviderMixin extends ChunkSource {
} }
@Inject(method = "replaceWithPacketData", at = @At("HEAD")) @Inject(method = "replaceWithPacketData", at = @At("HEAD"))
public void invalidateOnPacket(int x, int z, ChunkBiomeContainer p_228313_3_, FriendlyByteBuf p_228313_4_, CompoundTag p_228313_5_, int p_228313_6_, boolean p_228313_7_, CallbackInfoReturnable<LevelChunk> cir) { public void invalidateOnPacket(int x, int z, ChunkBiomeContainer p_171618_, FriendlyByteBuf p_171619_, CompoundTag p_171620_, BitSet p_171621_, CallbackInfoReturnable<LevelChunk> cir) {
if (Backend.getInstance().chunkCachingEnabled) { if (Backend.getInstance().chunkCachingEnabled) {
synchronized (level) { synchronized (level) {
if (x == lastX && z == lastZ) lastChunk = null; if (x == lastX && z == lastZ) lastChunk = null;

View file

@ -55,7 +55,7 @@ public class RenderHooksMixin {
* This should probably be a forge event. * This should probably be a forge event.
*/ */
@Inject(at = @At("TAIL"), method = "renderChunkLayer") @Inject(at = @At("TAIL"), method = "renderChunkLayer")
private void renderLayer(RenderType type, PoseStack stack, double camX, double camY, double camZ, CallbackInfo ci) { private void renderLayer(RenderType type, PoseStack stack, double camX, double camY, double camZ, Matrix4f p_172999_, CallbackInfo ci) {
RenderBuffers renderBuffers = this.renderBuffers; RenderBuffers renderBuffers = this.renderBuffers;
@ -75,7 +75,7 @@ public class RenderHooksMixin {
} }
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/WorldRenderer;checkPoseStack(Lcom/mojang/blaze3d/matrix/MatrixStack;)V", ordinal = 2 // after the game renders the breaking overlay normally @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;checkPoseStack(Lcom/mojang/blaze3d/vertex/PoseStack;)V", ordinal = 2 // after the game renders the breaking overlay normally
), method = "renderLevel") ), method = "renderLevel")
private void renderBlockBreaking(PoseStack stack, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, Camera info, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f p_228426_9_, CallbackInfo ci) { private void renderBlockBreaking(PoseStack stack, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, Camera info, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f p_228426_9_, CallbackInfo ci) {
if (!Backend.getInstance() if (!Backend.getInstance()
@ -98,7 +98,7 @@ public class RenderHooksMixin {
/** /**
* This gets called when a block is marked for rerender by vanilla. * This gets called when a block is marked for rerender by vanilla.
*/ */
@Inject(at = @At("TAIL"), method = "setBlockDirty(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)V") @Inject(at = @At("TAIL"), method = "setBlockDirty(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;)V")
private void checkUpdate(BlockPos pos, BlockState lastState, BlockState newState, CallbackInfo ci) { private void checkUpdate(BlockPos pos, BlockState lastState, BlockState newState, CallbackInfo ci) {
InstancedRenderDispatcher.getTiles(level) InstancedRenderDispatcher.getTiles(level)
.update(level.getBlockEntity(pos)); .update(level.getBlockEntity(pos));

View file

@ -22,7 +22,7 @@ public abstract class StoreProjectionMatrixMixin {
* We only want to copy the projection matrix if it is going to be used to render the world. * We only want to copy the projection matrix if it is going to be used to render the world.
* We don't care about the mat for your hand. * We don't care about the mat for your hand.
*/ */
@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;resetProjectionMatrix(Lnet/minecraft/util/math/vector/Matrix4f;)V")) @Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;resetProjectionMatrix(Lcom/mojang/math/Matrix4f;)V"))
private void projectionMatrixReady(float p_228378_1_, long p_228378_2_, PoseStack p_228378_4_, CallbackInfo ci) { private void projectionMatrixReady(float p_228378_1_, long p_228378_2_, PoseStack p_228378_4_, CallbackInfo ci) {
shouldCopy = true; shouldCopy = true;
} }

View file

@ -2,13 +2,14 @@ package com.jozufozu.flywheel.mixin;
import java.util.Set; import java.util.Set;
import net.minecraft.world.level.block.entity.TickingBlockEntity;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.jozufozu.flywheel.backend.instancing.InstanceManager; import com.jozufozu.flywheel.backend.instancing.InstanceManager;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher; import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
@ -30,13 +31,13 @@ public class TileWorldHookMixin {
@Shadow @Shadow
@Final @Final
protected Set<BlockEntity> blockEntitiesToUnload; protected Set<BlockEntity> f_46434_; // FIXME: is this correct?
@Inject(at = @At("TAIL"), method = "addBlockEntity") @Inject(at = @At("TAIL"), method = "addBlockEntityTicker(Lnet/minecraft/world/level/block/entity/TickingBlockEntity;)V")
private void onAddTile(BlockEntity te, CallbackInfoReturnable<Boolean> cir) { private void onAddTile(TickingBlockEntity te, CallbackInfo ci) {
if (isClientSide) { if (isClientSide) {
InstancedRenderDispatcher.getTiles(self) InstancedRenderDispatcher.getTiles(self)
.queueAdd(te); .queueAdd((BlockEntity) te);
} }
} }
@ -47,7 +48,7 @@ public class TileWorldHookMixin {
private void onChunkUnload(CallbackInfo ci) { private void onChunkUnload(CallbackInfo ci) {
if (isClientSide) { if (isClientSide) {
InstanceManager<BlockEntity> kineticRenderer = InstancedRenderDispatcher.getTiles(self); InstanceManager<BlockEntity> kineticRenderer = InstancedRenderDispatcher.getTiles(self);
for (BlockEntity tile : blockEntitiesToUnload) { for (BlockEntity tile : f_46434_) {
kineticRenderer.remove(tile); kineticRenderer.remove(tile);
} }
} }

View file

@ -62,7 +62,7 @@ public class MinecartInstance<T extends AbstractMinecart> extends EntityInstance
); );
float yaw = Mth.lerp(pt, entity.yRotO, entity.yRot); float yaw = Mth.lerp(pt, entity.yRotO, entity.getYRot());
long i = (long)entity.getId() * 493286711L; long i = (long)entity.getId() * 493286711L;
i = i * i * 4392167121L + i * 98761L; i = i * i * 4392167121L + i * 98761L;
@ -75,7 +75,7 @@ public class MinecartInstance<T extends AbstractMinecart> extends EntityInstance
double d1 = Mth.lerp(pt, entity.yOld, entity.getY()); double d1 = Mth.lerp(pt, entity.yOld, entity.getY());
double d2 = Mth.lerp(pt, entity.zOld, entity.getZ()); double d2 = Mth.lerp(pt, entity.zOld, entity.getZ());
Vec3 vector3d = entity.getPos(d0, d1, d2); Vec3 vector3d = entity.getPos(d0, d1, d2);
float f3 = Mth.lerp(pt, entity.xRotO, entity.xRot); float f3 = Mth.lerp(pt, entity.xRotO, entity.getXRot());
if (vector3d != null) { if (vector3d != null) {
Vec3 vector3d1 = entity.getPosOffs(d0, d1, d2, 0.3F); Vec3 vector3d1 = entity.getPosOffs(d0, d1, d2, 0.3F);
Vec3 vector3d2 = entity.getPosOffs(d0, d1, d2, -0.3F); Vec3 vector3d2 = entity.getPosOffs(d0, d1, d2, -0.3F);