mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-02-13 13:45:01 +01:00
Remap, update forge, minecraft and java
This commit is contained in:
parent
f4adf9b9c2
commit
2fc54ffbee
122 changed files with 658 additions and 656 deletions
|
@ -28,7 +28,7 @@ version = "${mc_update_version}-${mod_version}" + (dev ? ".${buildnumber}" : '')
|
||||||
group = 'com.jozufozu.flywheel'
|
group = 'com.jozufozu.flywheel'
|
||||||
archivesBaseName = 'flywheel'
|
archivesBaseName = 'flywheel'
|
||||||
|
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
|
java.toolchain.languageVersion = JavaLanguageVersion.of(16)
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
mappings channel: 'official', version: "${minecraft_version}"
|
mappings channel: 'official', version: "${minecraft_version}"
|
||||||
|
@ -143,6 +143,7 @@ artifacts {
|
||||||
archives jar, sourcesJar, javadocJar
|
archives jar, sourcesJar, javadocJar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
publishing {
|
publishing {
|
||||||
tasks.publish.dependsOn 'build'
|
tasks.publish.dependsOn 'build'
|
||||||
publications {
|
publications {
|
||||||
|
@ -174,3 +175,4 @@ curseforge {
|
||||||
mainArtifact jar
|
mainArtifact jar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -2,9 +2,9 @@ org.gradle.jvmargs=-Xmx3G
|
||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
# mod version info
|
# mod version info
|
||||||
mod_version=0.2.3
|
mod_version=0.2.3
|
||||||
mc_update_version=1.16
|
mc_update_version=1.17
|
||||||
minecraft_version=1.16.5
|
minecraft_version=1.17.1
|
||||||
forge_version=36.1.66
|
forge_version=37.0.59
|
||||||
|
|
||||||
# curseforge info
|
# curseforge info
|
||||||
projectId=486392
|
projectId=486392
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.jozufozu.flywheel.config.FlwCommands;
|
||||||
import com.jozufozu.flywheel.config.FlwConfig;
|
import com.jozufozu.flywheel.config.FlwConfig;
|
||||||
import com.jozufozu.flywheel.config.FlwPackets;
|
import com.jozufozu.flywheel.config.FlwPackets;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
|
|
|
@ -20,10 +20,10 @@ import com.jozufozu.flywheel.config.FlwConfig;
|
||||||
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
import com.mojang.math.Matrix4f;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
public class Backend {
|
public class Backend {
|
||||||
public static final Logger log = LogManager.getLogger(Backend.class);
|
public static final Logger log = LogManager.getLogger(Backend.class);
|
||||||
|
@ -144,7 +144,7 @@ public class Backend {
|
||||||
.chunkCaching();
|
.chunkCaching();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseInstancing(@Nullable World world) {
|
public boolean canUseInstancing(@Nullable Level world) {
|
||||||
return canUseInstancing() && isFlywheelWorld(world);
|
return canUseInstancing() && isFlywheelWorld(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ public class Backend {
|
||||||
/**
|
/**
|
||||||
* Used to avoid calling Flywheel functions on (fake) worlds that don't specifically support it.
|
* Used to avoid calling Flywheel functions on (fake) worlds that don't specifically support it.
|
||||||
*/
|
*/
|
||||||
public static boolean isFlywheelWorld(@Nullable IWorld world) {
|
public static boolean isFlywheelWorld(@Nullable LevelAccessor world) {
|
||||||
if (world == null) return false;
|
if (world == null) return false;
|
||||||
|
|
||||||
if (world instanceof IFlywheelWorld && ((IFlywheelWorld) world).supportsFlywheel()) return true;
|
if (world instanceof IFlywheelWorld && ((IFlywheelWorld) world).supportsFlywheel()) return true;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.util.function.Supplier;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public interface IShaderContext<P extends GlProgram> {
|
public interface IShaderContext<P extends GlProgram> {
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,11 @@ import com.mojang.serialization.DataResult;
|
||||||
import com.mojang.serialization.JsonOps;
|
import com.mojang.serialization.JsonOps;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.resources.IReloadableResourceManager;
|
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||||
import net.minecraft.resources.IResource;
|
import net.minecraft.server.packs.resources.Resource;
|
||||||
import net.minecraft.resources.IResourceManager;
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
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.ISelectiveResourceReloadListener;
|
||||||
|
@ -52,9 +52,9 @@ public class Loader implements ISelectiveResourceReloadListener {
|
||||||
// Can be null when running datagenerators due to the unfortunate time we call this
|
// Can be null when running datagenerators due to the unfortunate time we call this
|
||||||
Minecraft minecraft = Minecraft.getInstance();
|
Minecraft minecraft = Minecraft.getInstance();
|
||||||
if (minecraft != null) {
|
if (minecraft != null) {
|
||||||
IResourceManager manager = minecraft.getResourceManager();
|
ResourceManager manager = minecraft.getResourceManager();
|
||||||
if (manager instanceof IReloadableResourceManager) {
|
if (manager instanceof ReloadableResourceManager) {
|
||||||
((IReloadableResourceManager) manager).registerReloadListener(this);
|
((ReloadableResourceManager) manager).registerReloadListener(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class Loader implements ISelectiveResourceReloadListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResourceManagerReload(IResourceManager manager, Predicate<IResourceType> predicate) {
|
public void onResourceManagerReload(ResourceManager manager, Predicate<IResourceType> predicate) {
|
||||||
if (predicate.test(VanillaResourceType.SHADERS)) {
|
if (predicate.test(VanillaResourceType.SHADERS)) {
|
||||||
backend.refresh();
|
backend.refresh();
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ public class Loader implements ISelectiveResourceReloadListener {
|
||||||
|
|
||||||
Backend.log.info("Loaded all shader programs.");
|
Backend.log.info("Loaded all shader programs.");
|
||||||
|
|
||||||
ClientWorld world = Minecraft.getInstance().level;
|
ClientLevel world = Minecraft.getInstance().level;
|
||||||
if (Backend.isFlywheelWorld(world)) {
|
if (Backend.isFlywheelWorld(world)) {
|
||||||
// TODO: looks like it might be good to have another event here
|
// TODO: looks like it might be good to have another event here
|
||||||
InstancedRenderDispatcher.loadAllInWorld(world);
|
InstancedRenderDispatcher.loadAllInWorld(world);
|
||||||
|
@ -104,12 +104,12 @@ public class Loader implements ISelectiveResourceReloadListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadProgramSpecs(IResourceManager manager) {
|
private void loadProgramSpecs(ResourceManager manager) {
|
||||||
Collection<ResourceLocation> programSpecs = manager.listResources(PROGRAM_DIR, s -> s.endsWith(".json"));
|
Collection<ResourceLocation> programSpecs = manager.listResources(PROGRAM_DIR, s -> s.endsWith(".json"));
|
||||||
|
|
||||||
for (ResourceLocation location : programSpecs) {
|
for (ResourceLocation location : programSpecs) {
|
||||||
try {
|
try {
|
||||||
IResource file = manager.getResource(location);
|
Resource file = manager.getResource(location);
|
||||||
|
|
||||||
String s = StreamUtil.readToString(file.getInputStream());
|
String s = StreamUtil.readToString(file.getInputStream());
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.util.Map;
|
||||||
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
||||||
import com.jozufozu.flywheel.core.shader.gamestate.IGameStateProvider;
|
import com.jozufozu.flywheel.core.shader.gamestate.IGameStateProvider;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class SpecMetaRegistry {
|
public class SpecMetaRegistry {
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.gl.GlObject;
|
import com.jozufozu.flywheel.backend.gl.GlObject;
|
||||||
import com.jozufozu.flywheel.util.RenderUtil;
|
import com.jozufozu.flywheel.util.RenderUtil;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
import com.mojang.math.Matrix4f;
|
||||||
|
|
||||||
public abstract class GlProgram extends GlObject {
|
public abstract class GlProgram extends GlObject {
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.gl.GlObject;
|
import com.jozufozu.flywheel.backend.gl.GlObject;
|
||||||
import com.jozufozu.flywheel.backend.gl.versioned.GlCompat;
|
import com.jozufozu.flywheel.backend.gl.versioned.GlCompat;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class GlShader extends GlObject {
|
public class GlShader extends GlObject {
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,9 @@ import com.jozufozu.flywheel.light.ImmutableBox;
|
||||||
import com.jozufozu.flywheel.light.LightProvider;
|
import com.jozufozu.flywheel.light.LightProvider;
|
||||||
import com.jozufozu.flywheel.light.ListenerStatus;
|
import com.jozufozu.flywheel.light.ListenerStatus;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.LightType;
|
import net.minecraft.world.level.LightLayer;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A general interface providing information about any type of thing that could use Flywheel's instanced rendering.
|
* A general interface providing information about any type of thing that could use Flywheel's instanced rendering.
|
||||||
|
@ -22,9 +22,9 @@ import net.minecraft.world.World;
|
||||||
public abstract class AbstractInstance implements IInstance, ILightUpdateListener {
|
public abstract class AbstractInstance implements IInstance, ILightUpdateListener {
|
||||||
|
|
||||||
protected final MaterialManager materialManager;
|
protected final MaterialManager materialManager;
|
||||||
public final World world;
|
public final Level world;
|
||||||
|
|
||||||
public AbstractInstance(MaterialManager materialManager, World world) {
|
public AbstractInstance(MaterialManager materialManager, Level world) {
|
||||||
this.materialManager = materialManager;
|
this.materialManager = materialManager;
|
||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
@ -73,16 +73,16 @@ public abstract class AbstractInstance implements IInstance, ILightUpdateListene
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLightUpdate(LightProvider world, LightType type, ImmutableBox changed) {
|
public void onLightUpdate(LightProvider world, LightLayer type, ImmutableBox changed) {
|
||||||
updateLight();
|
updateLight();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void relight(BlockPos pos, IFlatLight<?>... models) {
|
protected void relight(BlockPos pos, IFlatLight<?>... models) {
|
||||||
relight(world.getBrightness(LightType.BLOCK, pos), world.getBrightness(LightType.SKY, pos), models);
|
relight(world.getBrightness(LightLayer.BLOCK, pos), world.getBrightness(LightLayer.SKY, pos), models);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <L extends IFlatLight<?>> void relight(BlockPos pos, Stream<L> models) {
|
protected <L extends IFlatLight<?>> void relight(BlockPos pos, Stream<L> models) {
|
||||||
relight(world.getBrightness(LightType.BLOCK, pos), world.getBrightness(LightType.SKY, pos), models);
|
relight(world.getBrightness(LightLayer.BLOCK, pos), world.getBrightness(LightLayer.SKY, pos), models);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void relight(int block, int sky, IFlatLight<?>... models) {
|
protected void relight(int block, int sky, IFlatLight<?>... models) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.jozufozu.flywheel.backend.instancing;
|
package com.jozufozu.flywheel.backend.instancing;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
public interface IInstance {
|
public interface IInstance {
|
||||||
BlockPos getWorldPosition();
|
BlockPos getWorldPosition();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.jozufozu.flywheel.backend.instancing;
|
package com.jozufozu.flywheel.backend.instancing;
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Something (a TileEntity or Entity) that can be rendered using the instancing API.
|
* Something (a TileEntity or Entity) that can be rendered using the instancing API.
|
||||||
|
@ -14,5 +14,5 @@ public interface IInstanceRendered {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
World getWorld();
|
Level getWorld();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,10 @@ import com.jozufozu.flywheel.backend.material.MaterialManagerImpl;
|
||||||
import com.jozufozu.flywheel.light.LightUpdater;
|
import com.jozufozu.flywheel.light.LightUpdater;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
import net.minecraft.client.Camera;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import com.mojang.math.Vector3f;
|
||||||
|
|
||||||
public abstract class InstanceManager<T> implements MaterialManagerImpl.OriginShiftListener {
|
public abstract class InstanceManager<T> implements MaterialManagerImpl.OriginShiftListener {
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ public abstract class InstanceManager<T> implements MaterialManagerImpl.OriginSh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beginFrame(ActiveRenderInfo info) {
|
public void beginFrame(Camera info) {
|
||||||
frame++;
|
frame++;
|
||||||
processQueuedAdditions();
|
processQueuedAdditions();
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ public abstract class InstanceManager<T> implements MaterialManagerImpl.OriginSh
|
||||||
|
|
||||||
int i = (dSq / 2048);
|
int i = (dSq / 2048);
|
||||||
|
|
||||||
return divisorSequence[MathHelper.clamp(i, 0, divisorSequence.length - 1)];
|
return divisorSequence[Mth.clamp(i, 0, divisorSequence.length - 1)];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addInternal(T tile) {
|
protected void addInternal(T tile) {
|
||||||
|
|
|
@ -10,9 +10,9 @@ import com.jozufozu.flywheel.event.BeginFrameEvent;
|
||||||
import com.jozufozu.flywheel.event.RenderLayerEvent;
|
import com.jozufozu.flywheel.event.RenderLayerEvent;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A manager class for a single world where instancing is supported.
|
* A manager class for a single world where instancing is supported.
|
||||||
|
@ -23,7 +23,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
public class InstanceWorld {
|
public class InstanceWorld {
|
||||||
protected final MaterialManagerImpl<WorldProgram> materialManager;
|
protected final MaterialManagerImpl<WorldProgram> materialManager;
|
||||||
protected final InstanceManager<Entity> entityInstanceManager;
|
protected final InstanceManager<Entity> entityInstanceManager;
|
||||||
protected final InstanceManager<TileEntity> tileEntityInstanceManager;
|
protected final InstanceManager<BlockEntity> tileEntityInstanceManager;
|
||||||
|
|
||||||
public InstanceWorld() {
|
public InstanceWorld() {
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public class InstanceWorld {
|
||||||
return entityInstanceManager;
|
return entityInstanceManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstanceManager<TileEntity> getTileEntityInstanceManager() {
|
public InstanceManager<BlockEntity> getTileEntityInstanceManager() {
|
||||||
return tileEntityInstanceManager;
|
return tileEntityInstanceManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class InstanceWorld {
|
||||||
/**
|
/**
|
||||||
* Instantiate all the necessary instances to render the given world.
|
* Instantiate all the necessary instances to render the given world.
|
||||||
*/
|
*/
|
||||||
public void loadAll(ClientWorld world) {
|
public void loadAll(ClientLevel world) {
|
||||||
world.blockEntityList.forEach(tileEntityInstanceManager::add);
|
world.blockEntityList.forEach(tileEntityInstanceManager::add);
|
||||||
world.entitiesForRendering()
|
world.entitiesForRendering()
|
||||||
.forEach(entityInstanceManager::add);
|
.forEach(entityInstanceManager::add);
|
||||||
|
|
|
@ -10,10 +10,10 @@ import com.jozufozu.flywheel.util.AnimationTickHolder;
|
||||||
import com.jozufozu.flywheel.util.WorldAttached;
|
import com.jozufozu.flywheel.util.WorldAttached;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.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.IWorld;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
|
@ -30,7 +30,7 @@ public class InstancedRenderDispatcher {
|
||||||
* Call this when you want to manually run {@link AbstractInstance#update()}.
|
* Call this when you want to manually run {@link AbstractInstance#update()}.
|
||||||
* @param te The tile whose instance you want to update.
|
* @param te The tile whose instance you want to update.
|
||||||
*/
|
*/
|
||||||
public static void enqueueUpdate(TileEntity te) {
|
public static void enqueueUpdate(BlockEntity te) {
|
||||||
getTiles(te.getLevel()).queueUpdate(te);
|
getTiles(te.getLevel()).queueUpdate(te);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,13 +43,13 @@ public class InstancedRenderDispatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static InstanceManager<TileEntity> getTiles(IWorld world) {
|
public static InstanceManager<BlockEntity> getTiles(LevelAccessor world) {
|
||||||
return instanceWorlds.get(world)
|
return instanceWorlds.get(world)
|
||||||
.getTileEntityInstanceManager();
|
.getTileEntityInstanceManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static InstanceManager<Entity> getEntities(IWorld world) {
|
public static InstanceManager<Entity> getEntities(LevelAccessor world) {
|
||||||
return instanceWorlds.get(world)
|
return instanceWorlds.get(world)
|
||||||
.getEntityInstanceManager();
|
.getEntityInstanceManager();
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class InstancedRenderDispatcher {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
ClientWorld world = mc.level;
|
ClientLevel world = mc.level;
|
||||||
AnimationTickHolder.tick();
|
AnimationTickHolder.tick();
|
||||||
|
|
||||||
instanceWorlds.get(world).tick();
|
instanceWorlds.get(world).tick();
|
||||||
|
@ -79,7 +79,7 @@ public class InstancedRenderDispatcher {
|
||||||
public static void renderLayer(RenderLayerEvent event) {
|
public static void renderLayer(RenderLayerEvent event) {
|
||||||
if (event.layer == null) return;
|
if (event.layer == null) return;
|
||||||
|
|
||||||
ClientWorld world = event.getWorld();
|
ClientLevel world = event.getWorld();
|
||||||
if (!Backend.getInstance()
|
if (!Backend.getInstance()
|
||||||
.canUseInstancing(world)) return;
|
.canUseInstancing(world)) return;
|
||||||
|
|
||||||
|
@ -88,14 +88,14 @@ public class InstancedRenderDispatcher {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onReloadRenderers(ReloadRenderersEvent event) {
|
public static void onReloadRenderers(ReloadRenderersEvent event) {
|
||||||
ClientWorld world = event.getWorld();
|
ClientLevel world = event.getWorld();
|
||||||
if (Backend.getInstance()
|
if (Backend.getInstance()
|
||||||
.canUseInstancing() && world != null) {
|
.canUseInstancing() && world != null) {
|
||||||
loadAllInWorld(world);
|
loadAllInWorld(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadAllInWorld(ClientWorld world) {
|
public static void loadAllInWorld(ClientLevel world) {
|
||||||
instanceWorlds.replace(world, InstanceWorld::delete)
|
instanceWorlds.replace(world, InstanceWorld::delete)
|
||||||
.loadAll(world);
|
.loadAll(world);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,10 @@ import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2BooleanLinkedOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2BooleanLinkedOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2BooleanMap;
|
import it.unimi.dsi.fastutil.objects.Object2BooleanMap;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
|
|
||||||
public class InstancedRenderRegistry {
|
public class InstancedRenderRegistry {
|
||||||
private static final InstancedRenderRegistry INSTANCE = new InstancedRenderRegistry();
|
private static final InstancedRenderRegistry INSTANCE = new InstancedRenderRegistry();
|
||||||
|
@ -26,14 +26,14 @@ public class InstancedRenderRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Object2BooleanMap<Object> skipRender = new Object2BooleanLinkedOpenHashMap<>();
|
private final Object2BooleanMap<Object> skipRender = new Object2BooleanLinkedOpenHashMap<>();
|
||||||
private final Map<TileEntityType<?>, ITileInstanceFactory<?>> tiles = Maps.newHashMap();
|
private final Map<BlockEntityType<?>, ITileInstanceFactory<?>> tiles = Maps.newHashMap();
|
||||||
private final Map<EntityType<?>, IEntityInstanceFactory<?>> entities = Maps.newHashMap();
|
private final Map<EntityType<?>, IEntityInstanceFactory<?>> entities = Maps.newHashMap();
|
||||||
|
|
||||||
protected InstancedRenderRegistry() {
|
protected InstancedRenderRegistry() {
|
||||||
skipRender.defaultReturnValue(false);
|
skipRender.defaultReturnValue(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends TileEntity> boolean shouldSkipRender(T type) {
|
public <T extends BlockEntity> boolean shouldSkipRender(T type) {
|
||||||
return _skipRender(type.getType()) || ((type instanceof IInstanceRendered) && !((IInstanceRendered) type).shouldRenderNormally());
|
return _skipRender(type.getType()) || ((type instanceof IInstanceRendered) && !((IInstanceRendered) type).shouldRenderNormally());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public class InstancedRenderRegistry {
|
||||||
return _skipRender(type.getType()) || ((type instanceof IInstanceRendered) && !((IInstanceRendered) type).shouldRenderNormally());
|
return _skipRender(type.getType()) || ((type instanceof IInstanceRendered) && !((IInstanceRendered) type).shouldRenderNormally());
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends TileEntity> boolean canInstance(TileEntityType<? extends T> type) {
|
public <T extends BlockEntity> boolean canInstance(BlockEntityType<? extends T> type) {
|
||||||
return tiles.containsKey(type);
|
return tiles.containsKey(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ public class InstancedRenderRegistry {
|
||||||
return entities.containsKey(type);
|
return entities.containsKey(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends TileEntity> TileConfig<? extends T> tile(TileEntityType<? extends T> type) {
|
public <T extends BlockEntity> TileConfig<? extends T> tile(BlockEntityType<? extends T> type) {
|
||||||
return new TileConfig<>(type);
|
return new TileConfig<>(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public class InstancedRenderRegistry {
|
||||||
* @deprecated will be removed in 0.3.0, use {@link #tile}
|
* @deprecated will be removed in 0.3.0, use {@link #tile}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public <T extends TileEntity> void register(TileEntityType<? extends T> type, ITileInstanceFactory<? super T> rendererFactory) {
|
public <T extends BlockEntity> void register(BlockEntityType<? extends T> type, ITileInstanceFactory<? super T> rendererFactory) {
|
||||||
this.tile(type)
|
this.tile(type)
|
||||||
.factory(rendererFactory);
|
.factory(rendererFactory);
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,8 @@ public class InstancedRenderRegistry {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Nullable
|
@Nullable
|
||||||
public <T extends TileEntity> TileEntityInstance<? super T> create(MaterialManager manager, T tile) {
|
public <T extends BlockEntity> TileEntityInstance<? super T> create(MaterialManager manager, T tile) {
|
||||||
TileEntityType<?> type = tile.getType();
|
BlockEntityType<?> type = tile.getType();
|
||||||
ITileInstanceFactory<? super T> factory = (ITileInstanceFactory<? super T>) this.tiles.get(type);
|
ITileInstanceFactory<? super T> factory = (ITileInstanceFactory<? super T>) this.tiles.get(type);
|
||||||
|
|
||||||
if (factory == null) return null;
|
if (factory == null) return null;
|
||||||
|
@ -107,12 +107,12 @@ public class InstancedRenderRegistry {
|
||||||
CONFIG setSkipRender(boolean skipRender);
|
CONFIG setSkipRender(boolean skipRender);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TileConfig<T extends TileEntity> implements Config<TileConfig<T>, ITileInstanceFactory<? super T>> {
|
public class TileConfig<T extends BlockEntity> implements Config<TileConfig<T>, ITileInstanceFactory<? super T>> {
|
||||||
|
|
||||||
|
|
||||||
private final TileEntityType<T> type;
|
private final BlockEntityType<T> type;
|
||||||
|
|
||||||
public TileConfig(TileEntityType<T> type) {
|
public TileConfig(BlockEntityType<T> type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,14 @@ import com.jozufozu.flywheel.light.ILightUpdateListener;
|
||||||
import com.jozufozu.flywheel.light.IMovingListener;
|
import com.jozufozu.flywheel.light.IMovingListener;
|
||||||
import com.jozufozu.flywheel.light.LightProvider;
|
import com.jozufozu.flywheel.light.LightProvider;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import com.mojang.math.Vector3f;
|
||||||
import net.minecraft.util.math.vector.Vector3i;
|
import net.minecraft.core.Vec3i;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The layer between a {@link TileEntity} and the Flywheel backend.
|
* The layer between a {@link TileEntity} and the Flywheel backend.
|
||||||
|
@ -52,7 +52,7 @@ public abstract class EntityInstance<E extends Entity> extends AbstractInstance
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(LightProvider provider) {
|
public boolean update(LightProvider provider) {
|
||||||
AxisAlignedBB boundsNow = entity.getBoundingBox();
|
AABB boundsNow = entity.getBoundingBox();
|
||||||
|
|
||||||
if (bounds.sameAs(boundsNow)) return false;
|
if (bounds.sameAs(boundsNow)) return false;
|
||||||
|
|
||||||
|
@ -71,8 +71,8 @@ public abstract class EntityInstance<E extends Entity> extends AbstractInstance
|
||||||
* @return The position this instance should be rendered at to appear in the correct location.
|
* @return The position this instance should be rendered at to appear in the correct location.
|
||||||
*/
|
*/
|
||||||
public Vector3f getInstancePosition() {
|
public Vector3f getInstancePosition() {
|
||||||
Vector3d pos = entity.position();
|
Vec3 pos = entity.position();
|
||||||
Vector3i origin = materialManager.getOriginCoordinate();
|
Vec3i origin = materialManager.getOriginCoordinate();
|
||||||
return new Vector3f((float) (pos.x - origin.getX()), (float) (pos.y - origin.getY()), (float) (pos.z - origin.getZ()));
|
return new Vector3f((float) (pos.x - origin.getX()), (float) (pos.y - origin.getY()), (float) (pos.z - origin.getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,12 +84,12 @@ public abstract class EntityInstance<E extends Entity> extends AbstractInstance
|
||||||
* @return The position this instance should be rendered at to appear in the correct location.
|
* @return The position this instance should be rendered at to appear in the correct location.
|
||||||
*/
|
*/
|
||||||
public Vector3f getInstancePosition(float partialTicks) {
|
public Vector3f getInstancePosition(float partialTicks) {
|
||||||
Vector3d pos = entity.position();
|
Vec3 pos = entity.position();
|
||||||
Vector3i origin = materialManager.getOriginCoordinate();
|
Vec3i origin = materialManager.getOriginCoordinate();
|
||||||
return new Vector3f(
|
return new Vector3f(
|
||||||
(float) (MathHelper.lerp(partialTicks, entity.xOld, pos.x) - origin.getX()),
|
(float) (Mth.lerp(partialTicks, entity.xOld, pos.x) - origin.getX()),
|
||||||
(float) (MathHelper.lerp(partialTicks, entity.yOld, pos.y) - origin.getY()),
|
(float) (Mth.lerp(partialTicks, entity.yOld, pos.y) - origin.getY()),
|
||||||
(float) (MathHelper.lerp(partialTicks, entity.zOld, pos.z) - origin.getZ())
|
(float) (Mth.lerp(partialTicks, entity.zOld, pos.z) - origin.getZ())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@ import com.jozufozu.flywheel.backend.instancing.InstanceManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
||||||
import com.jozufozu.flywheel.backend.material.MaterialManagerImpl;
|
import com.jozufozu.flywheel.backend.material.MaterialManagerImpl;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
public class EntityInstanceManager extends InstanceManager<Entity> {
|
public class EntityInstanceManager extends InstanceManager<Entity> {
|
||||||
|
|
||||||
|
@ -32,14 +32,14 @@ public class EntityInstanceManager extends InstanceManager<Entity> {
|
||||||
protected boolean canCreateInstance(Entity entity) {
|
protected boolean canCreateInstance(Entity entity) {
|
||||||
if (!entity.isAlive()) return false;
|
if (!entity.isAlive()) return false;
|
||||||
|
|
||||||
World world = entity.level;
|
Level world = entity.level;
|
||||||
|
|
||||||
if (world == null) return false;
|
if (world == null) return false;
|
||||||
|
|
||||||
if (Backend.isFlywheelWorld(world)) {
|
if (Backend.isFlywheelWorld(world)) {
|
||||||
BlockPos pos = entity.blockPosition();
|
BlockPos pos = entity.blockPosition();
|
||||||
|
|
||||||
IBlockReader existingChunk = world.getChunkForCollisions(pos.getX() >> 4, pos.getZ() >> 4);
|
BlockGetter existingChunk = world.getChunkForCollisions(pos.getX() >> 4, pos.getZ() >> 4);
|
||||||
|
|
||||||
return existingChunk != null;
|
return existingChunk != null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.backend.instancing.entity;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface IEntityInstanceFactory<E extends Entity> {
|
public interface IEntityInstanceFactory<E extends Entity> {
|
||||||
|
|
|
@ -2,9 +2,9 @@ package com.jozufozu.flywheel.backend.instancing.tile;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface ITileInstanceFactory<T extends TileEntity> {
|
public interface ITileInstanceFactory<T extends BlockEntity> {
|
||||||
TileEntityInstance<? super T> create(MaterialManager manager, T te);
|
TileEntityInstance<? super T> create(MaterialManager manager, T te);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@ import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
|
||||||
import com.jozufozu.flywheel.light.GridAlignedBB;
|
import com.jozufozu.flywheel.light.GridAlignedBB;
|
||||||
import com.jozufozu.flywheel.light.ImmutableBox;
|
import com.jozufozu.flywheel.light.ImmutableBox;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The layer between a {@link TileEntity} and the Flywheel backend.
|
* The layer between a {@link TileEntity} and the Flywheel backend.
|
||||||
|
@ -32,7 +32,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
*
|
*
|
||||||
* @param <T> The type of {@link TileEntity} your class is an instance of.
|
* @param <T> The type of {@link TileEntity} your class is an instance of.
|
||||||
*/
|
*/
|
||||||
public abstract class TileEntityInstance<T extends TileEntity> extends AbstractInstance {
|
public abstract class TileEntityInstance<T extends BlockEntity> extends AbstractInstance {
|
||||||
|
|
||||||
protected final T tile;
|
protected final T tile;
|
||||||
protected final BlockPos pos;
|
protected final BlockPos pos;
|
||||||
|
|
|
@ -6,33 +6,33 @@ import com.jozufozu.flywheel.backend.instancing.InstanceManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
||||||
import com.jozufozu.flywheel.backend.material.MaterialManagerImpl;
|
import com.jozufozu.flywheel.backend.material.MaterialManagerImpl;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
public class TileInstanceManager extends InstanceManager<TileEntity> {
|
public class TileInstanceManager extends InstanceManager<BlockEntity> {
|
||||||
|
|
||||||
public TileInstanceManager(MaterialManagerImpl<?> materialManager) {
|
public TileInstanceManager(MaterialManagerImpl<?> materialManager) {
|
||||||
super(materialManager);
|
super(materialManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canInstance(TileEntity obj) {
|
protected boolean canInstance(BlockEntity obj) {
|
||||||
return obj != null && InstancedRenderRegistry.getInstance().canInstance(obj.getType());
|
return obj != null && InstancedRenderRegistry.getInstance().canInstance(obj.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractInstance createRaw(TileEntity obj) {
|
protected AbstractInstance createRaw(BlockEntity obj) {
|
||||||
return InstancedRenderRegistry.getInstance()
|
return InstancedRenderRegistry.getInstance()
|
||||||
.create(materialManager, obj);
|
.create(materialManager, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canCreateInstance(TileEntity tile) {
|
protected boolean canCreateInstance(BlockEntity tile) {
|
||||||
if (tile.isRemoved()) return false;
|
if (tile.isRemoved()) return false;
|
||||||
|
|
||||||
World world = tile.getLevel();
|
Level world = tile.getLevel();
|
||||||
|
|
||||||
if (world == null) return false;
|
if (world == null) return false;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public class TileInstanceManager extends InstanceManager<TileEntity> {
|
||||||
if (Backend.isFlywheelWorld(world)) {
|
if (Backend.isFlywheelWorld(world)) {
|
||||||
BlockPos pos = tile.getBlockPos();
|
BlockPos pos = tile.getBlockPos();
|
||||||
|
|
||||||
IBlockReader existingChunk = world.getChunkForCollisions(pos.getX() >> 4, pos.getZ() >> 4);
|
BlockGetter existingChunk = world.getChunkForCollisions(pos.getX() >> 4, pos.getZ() >> 4);
|
||||||
|
|
||||||
return existingChunk != null;
|
return existingChunk != null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,10 @@ import com.jozufozu.flywheel.core.model.BlockModel;
|
||||||
import com.jozufozu.flywheel.core.model.IModel;
|
import com.jozufozu.flywheel.core.model.IModel;
|
||||||
import com.jozufozu.flywheel.util.Pair;
|
import com.jozufozu.flywheel.util.Pair;
|
||||||
import com.jozufozu.flywheel.util.RenderUtil;
|
import com.jozufozu.flywheel.util.RenderUtil;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.core.Direction;
|
||||||
|
|
||||||
public interface Material<D extends InstanceData> {
|
public interface Material<D extends InstanceData> {
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +32,7 @@ public interface Material<D extends InstanceData> {
|
||||||
return getModel(partial, referenceState, dir, RenderUtil.rotateToFace(dir));
|
return getModel(partial, referenceState, dir, RenderUtil.rotateToFace(dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
default Instancer<D> getModel(PartialModel partial, BlockState referenceState, Direction dir, Supplier<MatrixStack> modelTransform) {
|
default Instancer<D> getModel(PartialModel partial, BlockState referenceState, Direction dir, Supplier<PoseStack> modelTransform) {
|
||||||
return model(Pair.of(dir, partial), () -> new BlockModel(partial.get(), referenceState, modelTransform.get()));
|
return model(Pair.of(dir, partial), () -> new BlockModel(partial.get(), referenceState, modelTransform.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||||
import com.jozufozu.flywheel.backend.state.IRenderState;
|
import com.jozufozu.flywheel.backend.state.IRenderState;
|
||||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||||
|
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
import com.mojang.math.Matrix4f;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A group of materials all rendered with the same GL state.
|
* A group of materials all rendered with the same GL state.
|
||||||
|
|
|
@ -4,8 +4,8 @@ import com.jozufozu.flywheel.backend.state.IRenderState;
|
||||||
import com.jozufozu.flywheel.backend.state.RenderLayer;
|
import com.jozufozu.flywheel.backend.state.RenderLayer;
|
||||||
import com.jozufozu.flywheel.backend.state.TextureRenderState;
|
import com.jozufozu.flywheel.backend.state.TextureRenderState;
|
||||||
|
|
||||||
import net.minecraft.inventory.container.PlayerContainer;
|
import net.minecraft.world.inventory.InventoryMenu;
|
||||||
import net.minecraft.util.math.vector.Vector3i;
|
import net.minecraft.core.Vec3i;
|
||||||
|
|
||||||
public interface MaterialManager {
|
public interface MaterialManager {
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ public interface MaterialManager {
|
||||||
*/
|
*/
|
||||||
MaterialGroup state(RenderLayer layer, IRenderState state);
|
MaterialGroup state(RenderLayer layer, IRenderState state);
|
||||||
|
|
||||||
Vector3i getOriginCoordinate();
|
Vec3i getOriginCoordinate();
|
||||||
|
|
||||||
default MaterialGroup solid(IRenderState state) {
|
default MaterialGroup solid(IRenderState state) {
|
||||||
return state(RenderLayer.SOLID, state);
|
return state(RenderLayer.SOLID, state);
|
||||||
|
@ -33,14 +33,14 @@ public interface MaterialManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
default MaterialGroup defaultSolid() {
|
default MaterialGroup defaultSolid() {
|
||||||
return solid(TextureRenderState.get(PlayerContainer.BLOCK_ATLAS));
|
return solid(TextureRenderState.get(InventoryMenu.BLOCK_ATLAS));
|
||||||
}
|
}
|
||||||
|
|
||||||
default MaterialGroup defaultCutout() {
|
default MaterialGroup defaultCutout() {
|
||||||
return cutout(TextureRenderState.get(PlayerContainer.BLOCK_ATLAS));
|
return cutout(TextureRenderState.get(InventoryMenu.BLOCK_ATLAS));
|
||||||
}
|
}
|
||||||
|
|
||||||
default MaterialGroup defaultTransparent() {
|
default MaterialGroup defaultTransparent() {
|
||||||
return transparent(TextureRenderState.get(PlayerContainer.BLOCK_ATLAS));
|
return transparent(TextureRenderState.get(InventoryMenu.BLOCK_ATLAS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,12 @@ import com.jozufozu.flywheel.core.WorldContext;
|
||||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||||
import com.jozufozu.flywheel.util.WeakHashSet;
|
import com.jozufozu.flywheel.util.WeakHashSet;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
import net.minecraft.client.Camera;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
import com.mojang.math.Matrix4f;
|
||||||
import net.minecraft.util.math.vector.Vector3i;
|
import net.minecraft.core.Vec3i;
|
||||||
|
|
||||||
public class MaterialManagerImpl<P extends WorldProgram> implements MaterialManager {
|
public class MaterialManagerImpl<P extends WorldProgram> implements MaterialManager {
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ public class MaterialManagerImpl<P extends WorldProgram> implements MaterialMana
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector3i getOriginCoordinate() {
|
public Vec3i getOriginCoordinate() {
|
||||||
return originCoordinate;
|
return originCoordinate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,10 +118,10 @@ public class MaterialManagerImpl<P extends WorldProgram> implements MaterialMana
|
||||||
*
|
*
|
||||||
* This prevents floating point precision issues at high coordinates.
|
* This prevents floating point precision issues at high coordinates.
|
||||||
*/
|
*/
|
||||||
public void beginFrame(ActiveRenderInfo info) {
|
public void beginFrame(Camera info) {
|
||||||
int cX = MathHelper.floor(info.getPosition().x);
|
int cX = Mth.floor(info.getPosition().x);
|
||||||
int cY = MathHelper.floor(info.getPosition().y);
|
int cY = Mth.floor(info.getPosition().y);
|
||||||
int cZ = MathHelper.floor(info.getPosition().z);
|
int cZ = Mth.floor(info.getPosition().z);
|
||||||
|
|
||||||
int dX = cX - originCoordinate.getX();
|
int dX = cX - originCoordinate.getX();
|
||||||
int dY = cY - originCoordinate.getY();
|
int dY = cY - originCoordinate.getY();
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.util.function.Supplier;
|
||||||
import com.jozufozu.flywheel.backend.instancing.GPUInstancer;
|
import com.jozufozu.flywheel.backend.instancing.GPUInstancer;
|
||||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||||
|
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
import com.mojang.math.Matrix4f;
|
||||||
|
|
||||||
public class MaterialRenderer<P extends WorldProgram> {
|
public class MaterialRenderer<P extends WorldProgram> {
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||||
import com.jozufozu.flywheel.backend.struct.StructType;
|
import com.jozufozu.flywheel.backend.struct.StructType;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class MaterialSpec<D extends InstanceData> {
|
public class MaterialSpec<D extends InstanceData> {
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import com.jozufozu.flywheel.backend.gl.shader.ShaderType;
|
||||||
import com.jozufozu.flywheel.backend.source.FileResolution;
|
import com.jozufozu.flywheel.backend.source.FileResolution;
|
||||||
import com.jozufozu.flywheel.backend.source.SourceFile;
|
import com.jozufozu.flywheel.backend.source.SourceFile;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class WorldShader {
|
public class WorldShader {
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||||
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
||||||
import com.jozufozu.flywheel.core.shader.spec.ProgramState;
|
import com.jozufozu.flywheel.core.shader.spec.ProgramState;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class WorldShaderPipeline<P extends WorldProgram> implements IShaderPipeline<P> {
|
public class WorldShaderPipeline<P extends WorldProgram> implements IShaderPipeline<P> {
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.source.error.ErrorBuilder;
|
import com.jozufozu.flywheel.backend.source.error.ErrorBuilder;
|
||||||
import com.jozufozu.flywheel.backend.source.span.Span;
|
import com.jozufozu.flywheel.backend.source.span.Span;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A reference to a source file that might not be loaded when the owning object is created.
|
* A reference to a source file that might not be loaded when the owning object is created.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.jozufozu.flywheel.backend.source;
|
package com.jozufozu.flywheel.backend.source;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A minimal source file lookup function.
|
* A minimal source file lookup function.
|
||||||
|
|
|
@ -8,7 +8,7 @@ import com.google.common.collect.MultimapBuilder;
|
||||||
import com.jozufozu.flywheel.backend.source.parse.ShaderFunction;
|
import com.jozufozu.flywheel.backend.source.parse.ShaderFunction;
|
||||||
import com.jozufozu.flywheel.backend.source.parse.ShaderStruct;
|
import com.jozufozu.flywheel.backend.source.parse.ShaderStruct;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indexes many shader source definitions to allow for error fix suggestions.
|
* Indexes many shader source definitions to allow for error fix suggestions.
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.jozufozu.flywheel.backend.source;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages deferred file resolution.
|
* Manages deferred file resolution.
|
||||||
|
|
|
@ -10,9 +10,9 @@ import com.google.common.collect.Lists;
|
||||||
import com.jozufozu.flywheel.util.ResourceUtil;
|
import com.jozufozu.flywheel.util.ResourceUtil;
|
||||||
import com.jozufozu.flywheel.util.StreamUtil;
|
import com.jozufozu.flywheel.util.StreamUtil;
|
||||||
|
|
||||||
import net.minecraft.resources.IResource;
|
import net.minecraft.server.packs.resources.Resource;
|
||||||
import net.minecraft.resources.IResourceManager;
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main object for loading and parsing source files.
|
* The main object for loading and parsing source files.
|
||||||
|
@ -25,7 +25,7 @@ public class ShaderSources implements ISourceHolder {
|
||||||
|
|
||||||
public final Index index;
|
public final Index index;
|
||||||
|
|
||||||
public ShaderSources(IResourceManager manager) {
|
public ShaderSources(ResourceManager manager) {
|
||||||
Collection<ResourceLocation> allShaders = manager.listResources(SHADER_DIR, s -> {
|
Collection<ResourceLocation> allShaders = manager.listResources(SHADER_DIR, s -> {
|
||||||
for (String ext : EXTENSIONS) {
|
for (String ext : EXTENSIONS) {
|
||||||
if (s.endsWith(ext)) return true;
|
if (s.endsWith(ext)) return true;
|
||||||
|
@ -35,7 +35,7 @@ public class ShaderSources implements ISourceHolder {
|
||||||
|
|
||||||
for (ResourceLocation location : allShaders) {
|
for (ResourceLocation location : allShaders) {
|
||||||
try {
|
try {
|
||||||
IResource resource = manager.getResource(location);
|
Resource resource = manager.getResource(location);
|
||||||
|
|
||||||
String source = StreamUtil.readToString(resource.getInputStream());
|
String source = StreamUtil.readToString(resource.getInputStream());
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import com.jozufozu.flywheel.util.StringUtil;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
import it.unimi.dsi.fastutil.ints.IntList;
|
import it.unimi.dsi.fastutil.ints.IntList;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class SourceFile {
|
public class SourceFile {
|
||||||
private static final Pattern includePattern = Pattern.compile("#use \"(.*)\"");
|
private static final Pattern includePattern = Pattern.compile("#use \"(.*)\"");
|
||||||
|
|
|
@ -12,7 +12,7 @@ import com.jozufozu.flywheel.backend.source.SourceFile;
|
||||||
import com.jozufozu.flywheel.backend.source.error.ErrorReporter;
|
import com.jozufozu.flywheel.backend.source.error.ErrorReporter;
|
||||||
import com.jozufozu.flywheel.backend.source.span.Span;
|
import com.jozufozu.flywheel.backend.source.span.Span;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class Import extends AbstractShaderElement {
|
public class Import extends AbstractShaderElement {
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
|
import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public interface IRenderState {
|
public interface IRenderState {
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import javax.annotation.Nullable;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
|
import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class RenderState implements IRenderState {
|
public class RenderState implements IRenderState {
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
|
||||||
import com.jozufozu.flywheel.util.Pair;
|
import com.jozufozu.flywheel.util.Pair;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class TextureRenderState implements IRenderState {
|
public class TextureRenderState implements IRenderState {
|
||||||
private static final Map<Pair<GlTextureUnit, ResourceLocation>, TextureRenderState> states = new HashMap<>();
|
private static final Map<Pair<GlTextureUnit, ResourceLocation>, TextureRenderState> states = new HashMap<>();
|
||||||
|
|
|
@ -7,11 +7,11 @@ import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.OptifineHandler;
|
import com.jozufozu.flywheel.backend.OptifineHandler;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
import net.minecraft.util.text.IFormattableTextComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
@ -33,11 +33,11 @@ public enum BooleanConfig {
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
private static void enabled(BooleanDirective state) {
|
private static void enabled(BooleanDirective state) {
|
||||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
LocalPlayer player = Minecraft.getInstance().player;
|
||||||
if (player == null || state == null) return;
|
if (player == null || state == null) return;
|
||||||
|
|
||||||
if (state == BooleanDirective.DISPLAY) {
|
if (state == BooleanDirective.DISPLAY) {
|
||||||
ITextComponent text = new StringTextComponent("Flywheel renderer is currently: ").append(boolToText(FlwConfig.get().client.enabled.get()));
|
Component text = new TextComponent("Flywheel renderer is currently: ").append(boolToText(FlwConfig.get().client.enabled.get()));
|
||||||
player.displayClientMessage(text, false);
|
player.displayClientMessage(text, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -47,8 +47,8 @@ public enum BooleanConfig {
|
||||||
|
|
||||||
FlwConfig.get().client.enabled.set(enabled);
|
FlwConfig.get().client.enabled.set(enabled);
|
||||||
|
|
||||||
ITextComponent text = boolToText(FlwConfig.get().client.enabled.get()).append(new StringTextComponent(" Flywheel renderer").withStyle(TextFormatting.WHITE));
|
Component text = boolToText(FlwConfig.get().client.enabled.get()).append(new TextComponent(" Flywheel renderer").withStyle(ChatFormatting.WHITE));
|
||||||
ITextComponent error = new StringTextComponent("Flywheel renderer does not support Optifine Shaders").withStyle(TextFormatting.RED);
|
Component error = new TextComponent("Flywheel renderer does not support Optifine Shaders").withStyle(ChatFormatting.RED);
|
||||||
|
|
||||||
player.displayClientMessage(cannotUse ? error : text, false);
|
player.displayClientMessage(cannotUse ? error : text, false);
|
||||||
Backend.reloadWorldRenderers();
|
Backend.reloadWorldRenderers();
|
||||||
|
@ -56,42 +56,42 @@ public enum BooleanConfig {
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
private static void normalOverlay(BooleanDirective state) {
|
private static void normalOverlay(BooleanDirective state) {
|
||||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
LocalPlayer player = Minecraft.getInstance().player;
|
||||||
if (player == null || state == null) return;
|
if (player == null || state == null) return;
|
||||||
|
|
||||||
if (state == BooleanDirective.DISPLAY) {
|
if (state == BooleanDirective.DISPLAY) {
|
||||||
ITextComponent text = new StringTextComponent("Normal debug mode is currently: ").append(boolToText(FlwConfig.get().client.debugNormals.get()));
|
Component text = new TextComponent("Normal debug mode is currently: ").append(boolToText(FlwConfig.get().client.debugNormals.get()));
|
||||||
player.displayClientMessage(text, false);
|
player.displayClientMessage(text, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FlwConfig.get().client.debugNormals.set(state.get());
|
FlwConfig.get().client.debugNormals.set(state.get());
|
||||||
|
|
||||||
ITextComponent text = boolToText(FlwConfig.get().client.debugNormals.get()).append(new StringTextComponent(" normal debug mode").withStyle(TextFormatting.WHITE));
|
Component text = boolToText(FlwConfig.get().client.debugNormals.get()).append(new TextComponent(" normal debug mode").withStyle(ChatFormatting.WHITE));
|
||||||
|
|
||||||
player.displayClientMessage(text, false);
|
player.displayClientMessage(text, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
private static void chunkCaching(BooleanDirective state) {
|
private static void chunkCaching(BooleanDirective state) {
|
||||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
LocalPlayer player = Minecraft.getInstance().player;
|
||||||
if (player == null || state == null) return;
|
if (player == null || state == null) return;
|
||||||
|
|
||||||
if (state == BooleanDirective.DISPLAY) {
|
if (state == BooleanDirective.DISPLAY) {
|
||||||
ITextComponent text = new StringTextComponent("Chunk caching is currently: ").append(boolToText(FlwConfig.get().client.chunkCaching.get()));
|
Component text = new TextComponent("Chunk caching is currently: ").append(boolToText(FlwConfig.get().client.chunkCaching.get()));
|
||||||
player.displayClientMessage(text, false);
|
player.displayClientMessage(text, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FlwConfig.get().client.chunkCaching.set(state.get());
|
FlwConfig.get().client.chunkCaching.set(state.get());
|
||||||
|
|
||||||
ITextComponent text = boolToText(FlwConfig.get().client.chunkCaching.get()).append(new StringTextComponent(" chunk caching").withStyle(TextFormatting.WHITE));
|
Component text = boolToText(FlwConfig.get().client.chunkCaching.get()).append(new TextComponent(" chunk caching").withStyle(ChatFormatting.WHITE));
|
||||||
|
|
||||||
player.displayClientMessage(text, false);
|
player.displayClientMessage(text, false);
|
||||||
Backend.reloadWorldRenderers();
|
Backend.reloadWorldRenderers();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IFormattableTextComponent boolToText(boolean b) {
|
private static MutableComponent boolToText(boolean b) {
|
||||||
return b ? new StringTextComponent("enabled").withStyle(TextFormatting.DARK_GREEN) : new StringTextComponent("disabled").withStyle(TextFormatting.RED);
|
return b ? new TextComponent("enabled").withStyle(ChatFormatting.DARK_GREEN) : new TextComponent("disabled").withStyle(ChatFormatting.RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package com.jozufozu.flywheel.config;
|
||||||
import com.mojang.brigadier.Command;
|
import com.mojang.brigadier.Command;
|
||||||
import com.mojang.brigadier.builder.ArgumentBuilder;
|
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||||
|
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.command.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraftforge.fml.network.PacketDistributor;
|
import net.minecraftforge.fml.network.PacketDistributor;
|
||||||
|
|
||||||
public class BooleanConfigCommand {
|
public class BooleanConfigCommand {
|
||||||
|
@ -19,24 +19,24 @@ public class BooleanConfigCommand {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArgumentBuilder<CommandSource, ?> register() {
|
public ArgumentBuilder<CommandSourceStack, ?> register() {
|
||||||
return Commands.literal(name)
|
return Commands.literal(name)
|
||||||
.executes(context -> {
|
.executes(context -> {
|
||||||
ServerPlayerEntity player = context.getSource()
|
ServerPlayer player = context.getSource()
|
||||||
.getPlayerOrException();
|
.getPlayerOrException();
|
||||||
FlwPackets.channel.send(PacketDistributor.PLAYER.with(() -> player), new SConfigureBooleanPacket(value, BooleanDirective.DISPLAY));
|
FlwPackets.channel.send(PacketDistributor.PLAYER.with(() -> player), new SConfigureBooleanPacket(value, BooleanDirective.DISPLAY));
|
||||||
return Command.SINGLE_SUCCESS;
|
return Command.SINGLE_SUCCESS;
|
||||||
})
|
})
|
||||||
.then(Commands.literal("on")
|
.then(Commands.literal("on")
|
||||||
.executes(context -> {
|
.executes(context -> {
|
||||||
ServerPlayerEntity player = context.getSource()
|
ServerPlayer player = context.getSource()
|
||||||
.getPlayerOrException();
|
.getPlayerOrException();
|
||||||
FlwPackets.channel.send(PacketDistributor.PLAYER.with(() -> player), new SConfigureBooleanPacket(value, BooleanDirective.TRUE));
|
FlwPackets.channel.send(PacketDistributor.PLAYER.with(() -> player), new SConfigureBooleanPacket(value, BooleanDirective.TRUE));
|
||||||
return Command.SINGLE_SUCCESS;
|
return Command.SINGLE_SUCCESS;
|
||||||
}))
|
}))
|
||||||
.then(Commands.literal("off")
|
.then(Commands.literal("off")
|
||||||
.executes(context -> {
|
.executes(context -> {
|
||||||
ServerPlayerEntity player = context.getSource()
|
ServerPlayer player = context.getSource()
|
||||||
.getPlayerOrException();
|
.getPlayerOrException();
|
||||||
FlwPackets.channel.send(PacketDistributor.PLAYER.with(() -> player), new SConfigureBooleanPacket(value, BooleanDirective.FALSE));
|
FlwPackets.channel.send(PacketDistributor.PLAYER.with(() -> player), new SConfigureBooleanPacket(value, BooleanDirective.FALSE));
|
||||||
return Command.SINGLE_SUCCESS;
|
return Command.SINGLE_SUCCESS;
|
||||||
|
|
|
@ -2,15 +2,15 @@ package com.jozufozu.flywheel.config;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.command.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.fml.event.server.FMLServerStartingEvent;
|
||||||
|
|
||||||
public class FlwCommands {
|
public class FlwCommands {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onServerStarting(FMLServerStartingEvent event) {
|
public static void onServerStarting(FMLServerStartingEvent event) {
|
||||||
CommandDispatcher<CommandSource> dispatcher = event.getServer()
|
CommandDispatcher<CommandSourceStack> dispatcher = event.getServer()
|
||||||
.getCommands()
|
.getCommands()
|
||||||
.getDispatcher();
|
.getDispatcher();
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.config;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.Flywheel;
|
import com.jozufozu.flywheel.Flywheel;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraftforge.fml.network.NetworkDirection;
|
import net.minecraftforge.fml.network.NetworkDirection;
|
||||||
import net.minecraftforge.fml.network.NetworkRegistry;
|
import net.minecraftforge.fml.network.NetworkRegistry;
|
||||||
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.config;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraftforge.fml.network.NetworkEvent;
|
import net.minecraftforge.fml.network.NetworkEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,12 +18,12 @@ public class SConfigureBooleanPacket {
|
||||||
this.directive = directive;
|
this.directive = directive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SConfigureBooleanPacket(PacketBuffer buffer) {
|
public SConfigureBooleanPacket(FriendlyByteBuf buffer) {
|
||||||
target = BooleanConfig.values()[buffer.readByte()];
|
target = BooleanConfig.values()[buffer.readByte()];
|
||||||
directive = BooleanDirective.values()[buffer.readByte()];
|
directive = BooleanDirective.values()[buffer.readByte()];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void encode(PacketBuffer buffer) {
|
public void encode(FriendlyByteBuf buffer) {
|
||||||
buffer.writeByte(target.ordinal());
|
buffer.writeByte(target.ordinal());
|
||||||
buffer.writeByte(directive.ordinal());
|
buffer.writeByte(directive.ordinal());
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@ package com.jozufozu.flywheel.core;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.inventory.container.PlayerContainer;
|
import net.minecraft.world.inventory.InventoryMenu;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,7 +30,7 @@ public class AtlasStitcher {
|
||||||
public void onTextureStitch(TextureStitchEvent.Pre event) {
|
public void onTextureStitch(TextureStitchEvent.Pre event) {
|
||||||
if (!event.getMap()
|
if (!event.getMap()
|
||||||
.location()
|
.location()
|
||||||
.equals(PlayerContainer.BLOCK_ATLAS)) return;
|
.equals(InventoryMenu.BLOCK_ATLAS)) return;
|
||||||
|
|
||||||
sprites.forEach(StitchedSprite::reset);
|
sprites.forEach(StitchedSprite::reset);
|
||||||
sprites.stream()
|
sprites.stream()
|
||||||
|
|
|
@ -16,7 +16,7 @@ import com.jozufozu.flywheel.core.shader.gamestate.NormalDebugStateProvider;
|
||||||
import com.jozufozu.flywheel.event.GatherContextEvent;
|
import com.jozufozu.flywheel.event.GatherContextEvent;
|
||||||
import com.jozufozu.flywheel.util.ResourceUtil;
|
import com.jozufozu.flywheel.util.ResourceUtil;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
|
||||||
import com.jozufozu.flywheel.core.materials.oriented.OrientedType;
|
import com.jozufozu.flywheel.core.materials.oriented.OrientedType;
|
||||||
import com.jozufozu.flywheel.event.GatherContextEvent;
|
import com.jozufozu.flywheel.event.GatherContextEvent;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||||
import net.minecraftforge.client.model.ModelLoader;
|
import net.minecraftforge.client.model.ModelLoader;
|
||||||
|
@ -27,7 +27,7 @@ public class PartialModel {
|
||||||
private static final List<PartialModel> all = new ArrayList<>();
|
private static final List<PartialModel> all = new ArrayList<>();
|
||||||
|
|
||||||
protected final ResourceLocation modelLocation;
|
protected final ResourceLocation modelLocation;
|
||||||
protected IBakedModel bakedModel;
|
protected BakedModel bakedModel;
|
||||||
|
|
||||||
public PartialModel(ResourceLocation modelLocation) {
|
public PartialModel(ResourceLocation modelLocation) {
|
||||||
|
|
||||||
|
@ -45,12 +45,12 @@ public class PartialModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onModelBake(ModelBakeEvent event) {
|
public static void onModelBake(ModelBakeEvent event) {
|
||||||
Map<ResourceLocation, IBakedModel> modelRegistry = event.getModelRegistry();
|
Map<ResourceLocation, BakedModel> modelRegistry = event.getModelRegistry();
|
||||||
for (PartialModel partial : all)
|
for (PartialModel partial : all)
|
||||||
partial.bakedModel = modelRegistry.get(partial.modelLocation);
|
partial.bakedModel = modelRegistry.get(partial.modelLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBakedModel get() {
|
public BakedModel get() {
|
||||||
return bakedModel;
|
return bakedModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.core;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.Flywheel;
|
import com.jozufozu.flywheel.Flywheel;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class Programs {
|
public class Programs {
|
||||||
public static final ResourceLocation TRANSFORMED = new ResourceLocation(Flywheel.ID, "model");
|
public static final ResourceLocation TRANSFORMED = new ResourceLocation(Flywheel.ID, "model");
|
||||||
|
|
|
@ -2,8 +2,8 @@ package com.jozufozu.flywheel.core;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.inventory.container.PlayerContainer;
|
import net.minecraft.world.inventory.InventoryMenu;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class StitchedSprite {
|
public class StitchedSprite {
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ public class StitchedSprite {
|
||||||
public TextureAtlasSprite getSprite() {
|
public TextureAtlasSprite getSprite() {
|
||||||
if (sprite == null) {
|
if (sprite == null) {
|
||||||
sprite = Minecraft.getInstance()
|
sprite = Minecraft.getInstance()
|
||||||
.getTextureAtlas(PlayerContainer.BLOCK_ATLAS)
|
.getTextureAtlas(InventoryMenu.BLOCK_ATLAS)
|
||||||
.apply(loc);
|
.apply(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import com.jozufozu.flywheel.core.shader.IMultiProgram;
|
||||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||||
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class WorldContext<P extends WorldProgram> implements IShaderContext<P> {
|
public class WorldContext<P extends WorldProgram> implements IShaderContext<P> {
|
||||||
public final Backend backend;
|
public final Backend backend;
|
||||||
|
|
|
@ -6,20 +6,20 @@ import java.util.Map;
|
||||||
import com.jozufozu.flywheel.mixin.atlas.SheetDataAccessor;
|
import com.jozufozu.flywheel.mixin.atlas.SheetDataAccessor;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||||
import net.minecraft.client.renderer.texture.Texture;
|
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class AtlasInfo {
|
public class AtlasInfo {
|
||||||
|
|
||||||
private static final Map<ResourceLocation, SheetData> sheetData = new HashMap<>();
|
private static final Map<ResourceLocation, SheetData> sheetData = new HashMap<>();
|
||||||
|
|
||||||
public static AtlasTexture getAtlas(ResourceLocation name) {
|
public static TextureAtlas getAtlas(ResourceLocation name) {
|
||||||
Texture texture = Minecraft.getInstance().textureManager.getTexture(name);
|
AbstractTexture texture = Minecraft.getInstance().textureManager.getTexture(name);
|
||||||
|
|
||||||
if (texture instanceof AtlasTexture)
|
if (texture instanceof TextureAtlas)
|
||||||
return (AtlasTexture) texture;
|
return (TextureAtlas) texture;
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class AtlasInfo {
|
||||||
return getAtlasData(texture.atlas());
|
return getAtlasData(texture.atlas());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SheetData getAtlasData(AtlasTexture atlas) {
|
public static SheetData getAtlasData(TextureAtlas atlas) {
|
||||||
return getAtlasData(atlas.location());
|
return getAtlasData(atlas.location());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import com.jozufozu.flywheel.backend.state.IRenderState;
|
||||||
import com.jozufozu.flywheel.core.atlas.AtlasInfo;
|
import com.jozufozu.flywheel.core.atlas.AtlasInfo;
|
||||||
import com.jozufozu.flywheel.core.atlas.SheetData;
|
import com.jozufozu.flywheel.core.atlas.SheetData;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class CrumblingGroup<P extends CrumblingProgram> extends MaterialGroupImpl<P> {
|
public class CrumblingGroup<P extends CrumblingProgram> extends MaterialGroupImpl<P> {
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.jozufozu.flywheel.core.crumbling;
|
||||||
import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager;
|
import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager;
|
||||||
import com.jozufozu.flywheel.backend.material.MaterialManagerImpl;
|
import com.jozufozu.flywheel.backend.material.MaterialManagerImpl;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
public class CrumblingInstanceManager extends TileInstanceManager {
|
public class CrumblingInstanceManager extends TileInstanceManager {
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,11 @@ import com.jozufozu.flywheel.core.atlas.AtlasInfo;
|
||||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||||
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.model.ModelBakery;
|
import net.minecraft.client.resources.model.ModelBakery;
|
||||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.inventory.container.PlayerContainer;
|
import net.minecraft.world.inventory.InventoryMenu;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class CrumblingProgram extends WorldProgram {
|
public class CrumblingProgram extends WorldProgram {
|
||||||
protected final int uTextureScale;
|
protected final int uTextureScale;
|
||||||
|
@ -35,7 +35,7 @@ public class CrumblingProgram extends WorldProgram {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAtlasSize(int width, int height) {
|
public void setAtlasSize(int width, int height) {
|
||||||
AtlasTexture blockAtlas = AtlasInfo.getAtlas(PlayerContainer.BLOCK_ATLAS);
|
TextureAtlas blockAtlas = AtlasInfo.getAtlas(InventoryMenu.BLOCK_ATLAS);
|
||||||
if (blockAtlas == null) return;
|
if (blockAtlas == null) return;
|
||||||
|
|
||||||
TextureAtlasSprite sprite = blockAtlas.getSprite(ModelBakery.BREAKING_LOCATIONS.get(0));
|
TextureAtlasSprite sprite = blockAtlas.getSprite(ModelBakery.BREAKING_LOCATIONS.get(0));
|
||||||
|
|
|
@ -21,16 +21,16 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
import net.minecraft.client.Camera;
|
||||||
import net.minecraft.client.renderer.DestroyBlockProgress;
|
import net.minecraft.server.level.BlockDestructionProgress;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.model.ModelBakery;
|
import net.minecraft.client.resources.model.ModelBakery;
|
||||||
import net.minecraft.client.renderer.texture.Texture;
|
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
import com.mojang.math.Matrix4f;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
@ -53,28 +53,28 @@ public class CrumblingRenderer {
|
||||||
INVALIDATOR = state.getSecond();
|
INVALIDATOR = state.getSecond();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renderBreaking(ClientWorld world, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) {
|
public static void renderBreaking(ClientLevel world, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) {
|
||||||
if (!Backend.getInstance()
|
if (!Backend.getInstance()
|
||||||
.canUseInstancing(world)) return;
|
.canUseInstancing(world)) return;
|
||||||
|
|
||||||
Int2ObjectMap<List<TileEntity>> activeStages = getActiveStageTiles(world);
|
Int2ObjectMap<List<BlockEntity>> activeStages = getActiveStageTiles(world);
|
||||||
|
|
||||||
if (activeStages.isEmpty()) return;
|
if (activeStages.isEmpty()) return;
|
||||||
|
|
||||||
State state = STATE.get();
|
State state = STATE.get();
|
||||||
RenderType layer = ModelBakery.DESTROY_TYPES.get(0);
|
RenderType layer = ModelBakery.DESTROY_TYPES.get(0);
|
||||||
|
|
||||||
InstanceManager<TileEntity> renderer = state.instanceManager;
|
InstanceManager<BlockEntity> renderer = state.instanceManager;
|
||||||
|
|
||||||
TextureManager textureManager = Minecraft.getInstance().textureManager;
|
TextureManager textureManager = Minecraft.getInstance().textureManager;
|
||||||
ActiveRenderInfo info = Minecraft.getInstance().gameRenderer.getMainCamera();
|
Camera info = Minecraft.getInstance().gameRenderer.getMainCamera();
|
||||||
|
|
||||||
MaterialManagerImpl<CrumblingProgram> materials = state.materialManager;
|
MaterialManagerImpl<CrumblingProgram> materials = state.materialManager;
|
||||||
layer.setupRenderState();
|
layer.setupRenderState();
|
||||||
|
|
||||||
for (Int2ObjectMap.Entry<List<TileEntity>> stage : activeStages.int2ObjectEntrySet()) {
|
for (Int2ObjectMap.Entry<List<BlockEntity>> stage : activeStages.int2ObjectEntrySet()) {
|
||||||
int i = stage.getIntKey();
|
int i = stage.getIntKey();
|
||||||
Texture breaking = textureManager.getTexture(ModelBakery.BREAKING_LOCATIONS.get(i));
|
AbstractTexture breaking = textureManager.getTexture(ModelBakery.BREAKING_LOCATIONS.get(i));
|
||||||
|
|
||||||
// something about when we call this means that the textures are not ready for use on the first frame they should appear
|
// something about when we call this means that the textures are not ready for use on the first frame they should appear
|
||||||
if (breaking != null) {
|
if (breaking != null) {
|
||||||
|
@ -94,30 +94,30 @@ public class CrumblingRenderer {
|
||||||
layer.clearRenderState();
|
layer.clearRenderState();
|
||||||
|
|
||||||
GlTextureUnit.T0.makeActive();
|
GlTextureUnit.T0.makeActive();
|
||||||
Texture breaking = textureManager.getTexture(ModelBakery.BREAKING_LOCATIONS.get(0));
|
AbstractTexture breaking = textureManager.getTexture(ModelBakery.BREAKING_LOCATIONS.get(0));
|
||||||
if (breaking != null) glBindTexture(GL_TEXTURE_2D, breaking.getId());
|
if (breaking != null) glBindTexture(GL_TEXTURE_2D, breaking.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associate each breaking stage with a list of all tile entities at that stage.
|
* Associate each breaking stage with a list of all tile entities at that stage.
|
||||||
*/
|
*/
|
||||||
private static Int2ObjectMap<List<TileEntity>> getActiveStageTiles(ClientWorld world) {
|
private static Int2ObjectMap<List<BlockEntity>> getActiveStageTiles(ClientLevel world) {
|
||||||
Long2ObjectMap<SortedSet<DestroyBlockProgress>> breakingProgressions = Minecraft.getInstance().levelRenderer.destructionProgress;
|
Long2ObjectMap<SortedSet<BlockDestructionProgress>> breakingProgressions = Minecraft.getInstance().levelRenderer.destructionProgress;
|
||||||
|
|
||||||
Int2ObjectMap<List<TileEntity>> breakingEntities = new Int2ObjectArrayMap<>();
|
Int2ObjectMap<List<BlockEntity>> breakingEntities = new Int2ObjectArrayMap<>();
|
||||||
|
|
||||||
for (Long2ObjectMap.Entry<SortedSet<DestroyBlockProgress>> entry : breakingProgressions.long2ObjectEntrySet()) {
|
for (Long2ObjectMap.Entry<SortedSet<BlockDestructionProgress>> entry : breakingProgressions.long2ObjectEntrySet()) {
|
||||||
BlockPos breakingPos = BlockPos.of(entry.getLongKey());
|
BlockPos breakingPos = BlockPos.of(entry.getLongKey());
|
||||||
|
|
||||||
SortedSet<DestroyBlockProgress> progresses = entry.getValue();
|
SortedSet<BlockDestructionProgress> progresses = entry.getValue();
|
||||||
if (progresses != null && !progresses.isEmpty()) {
|
if (progresses != null && !progresses.isEmpty()) {
|
||||||
int blockDamage = progresses.last()
|
int blockDamage = progresses.last()
|
||||||
.getProgress();
|
.getProgress();
|
||||||
|
|
||||||
TileEntity tileEntity = world.getBlockEntity(breakingPos);
|
BlockEntity tileEntity = world.getBlockEntity(breakingPos);
|
||||||
|
|
||||||
if (tileEntity != null) {
|
if (tileEntity != null) {
|
||||||
List<TileEntity> tileEntities = breakingEntities.computeIfAbsent(blockDamage, $ -> new ArrayList<>());
|
List<BlockEntity> tileEntities = breakingEntities.computeIfAbsent(blockDamage, $ -> new ArrayList<>());
|
||||||
tileEntities.add(tileEntity);
|
tileEntities.add(tileEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ public class CrumblingRenderer {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onReloadRenderers(ReloadRenderersEvent event) {
|
public static void onReloadRenderers(ReloadRenderersEvent event) {
|
||||||
ClientWorld world = event.getWorld();
|
ClientLevel world = event.getWorld();
|
||||||
if (Backend.getInstance()
|
if (Backend.getInstance()
|
||||||
.canUseInstancing() && world != null) {
|
.canUseInstancing() && world != null) {
|
||||||
reset();
|
reset();
|
||||||
|
@ -141,7 +141,7 @@ public class CrumblingRenderer {
|
||||||
|
|
||||||
private static class State {
|
private static class State {
|
||||||
private final MaterialManagerImpl<CrumblingProgram> materialManager;
|
private final MaterialManagerImpl<CrumblingProgram> materialManager;
|
||||||
private final InstanceManager<TileEntity> instanceManager;
|
private final InstanceManager<BlockEntity> instanceManager;
|
||||||
|
|
||||||
private State() {
|
private State() {
|
||||||
materialManager = MaterialManagerImpl.builder(Contexts.CRUMBLING)
|
materialManager = MaterialManagerImpl.builder(Contexts.CRUMBLING)
|
||||||
|
|
|
@ -3,14 +3,14 @@ package com.jozufozu.flywheel.core.materials.model;
|
||||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||||
import com.jozufozu.flywheel.core.materials.BasicData;
|
import com.jozufozu.flywheel.core.materials.BasicData;
|
||||||
import com.jozufozu.flywheel.util.RenderUtil;
|
import com.jozufozu.flywheel.util.RenderUtil;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
public class ModelData extends BasicData {
|
public class ModelData extends BasicData {
|
||||||
private static final float[] empty = new float[25];
|
private static final float[] empty = new float[25];
|
||||||
|
|
||||||
public float[] matrices = empty;
|
public float[] matrices = empty;
|
||||||
|
|
||||||
public ModelData setTransform(MatrixStack stack) {
|
public ModelData setTransform(PoseStack stack) {
|
||||||
matrices = RenderUtil.writeMatrixStack(stack);
|
matrices = RenderUtil.writeMatrixStack(stack);
|
||||||
markDirty();
|
markDirty();
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -4,10 +4,10 @@ import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||||
import com.jozufozu.flywheel.core.materials.BasicData;
|
import com.jozufozu.flywheel.core.materials.BasicData;
|
||||||
import com.jozufozu.flywheel.util.vec.Vec3;
|
import com.jozufozu.flywheel.util.vec.Vec3;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.vector.Quaternion;
|
import com.mojang.math.Quaternion;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import com.mojang.math.Vector3f;
|
||||||
|
|
||||||
public class OrientedData extends BasicData {
|
public class OrientedData extends BasicData {
|
||||||
|
|
||||||
|
@ -55,7 +55,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(Vector3d pos) {
|
public OrientedData setPivot(Vec3 pos) {
|
||||||
return setPosition((float) pos.x(), (float) pos.y(), (float) pos.z());
|
return setPosition((float) pos.x(), (float) pos.y(), (float) pos.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,13 @@ import com.jozufozu.flywheel.core.Formats;
|
||||||
import com.jozufozu.flywheel.util.VirtualEmptyModelData;
|
import com.jozufozu.flywheel.util.VirtualEmptyModelData;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.color.ItemColors;
|
import net.minecraft.client.color.item.ItemColors;
|
||||||
import net.minecraft.client.renderer.model.BakedQuad;
|
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import com.mojang.math.Vector3f;
|
||||||
import net.minecraft.util.math.vector.Vector3i;
|
import net.minecraft.core.Vec3i;
|
||||||
|
|
||||||
public class BakedModelModel implements IModel {
|
public class BakedModelModel implements IModel {
|
||||||
// DOWN, UP, NORTH, SOUTH, WEST, EAST, null
|
// DOWN, UP, NORTH, SOUTH, WEST, EAST, null
|
||||||
|
@ -36,10 +36,10 @@ public class BakedModelModel implements IModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final IBakedModel model;
|
public final BakedModel model;
|
||||||
private final int numQuads;
|
private final int numQuads;
|
||||||
|
|
||||||
public BakedModelModel(IBakedModel model) {
|
public BakedModelModel(BakedModel model) {
|
||||||
this.model = model;
|
this.model = model;
|
||||||
|
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
@ -80,13 +80,13 @@ public class BakedModelModel implements IModel {
|
||||||
// byte blue = (byte)(i & 255);
|
// byte blue = (byte)(i & 255);
|
||||||
|
|
||||||
int[] aint = bakedQuad.getVertices();
|
int[] aint = bakedQuad.getVertices();
|
||||||
Vector3i faceNormal = bakedQuad.getDirection().getNormal();
|
Vec3i faceNormal = bakedQuad.getDirection().getNormal();
|
||||||
Vector3f normal = new Vector3f((float)faceNormal.getX(), (float)faceNormal.getY(), (float)faceNormal.getZ());
|
Vector3f normal = new Vector3f((float)faceNormal.getX(), (float)faceNormal.getY(), (float)faceNormal.getZ());
|
||||||
int intSize = DefaultVertexFormats.BLOCK.getIntegerSize();
|
int intSize = DefaultVertexFormat.BLOCK.getIntegerSize();
|
||||||
int vertexCount = aint.length / intSize;
|
int vertexCount = aint.length / intSize;
|
||||||
|
|
||||||
try (MemoryStack memorystack = MemoryStack.stackPush()) {
|
try (MemoryStack memorystack = MemoryStack.stackPush()) {
|
||||||
ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormats.BLOCK.getVertexSize());
|
ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormat.BLOCK.getVertexSize());
|
||||||
IntBuffer intbuffer = bytebuffer.asIntBuffer();
|
IntBuffer intbuffer = bytebuffer.asIntBuffer();
|
||||||
|
|
||||||
for(int j = 0; j < vertexCount; ++j) {
|
for(int j = 0; j < vertexCount; ++j) {
|
||||||
|
|
|
@ -9,24 +9,24 @@ import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||||
import com.jozufozu.flywheel.core.Formats;
|
import com.jozufozu.flywheel.core.Formats;
|
||||||
import com.jozufozu.flywheel.util.BufferBuilderReader;
|
import com.jozufozu.flywheel.util.BufferBuilderReader;
|
||||||
import com.jozufozu.flywheel.util.VirtualEmptyModelData;
|
import com.jozufozu.flywheel.util.VirtualEmptyModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.BlockModelRenderer;
|
import net.minecraft.client.renderer.block.ModelBlockRenderer;
|
||||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A model of a single block.
|
* A model of a single block.
|
||||||
*/
|
*/
|
||||||
public class BlockModel implements IModel {
|
public class BlockModel implements IModel {
|
||||||
private static final MatrixStack IDENTITY = new MatrixStack();
|
private static final PoseStack IDENTITY = new PoseStack();
|
||||||
|
|
||||||
private final BufferBuilderReader reader;
|
private final BufferBuilderReader reader;
|
||||||
|
|
||||||
|
@ -36,11 +36,11 @@ public class BlockModel implements IModel {
|
||||||
.getBlockModel(state), state);
|
.getBlockModel(state), state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockModel(IBakedModel model, BlockState referenceState) {
|
public BlockModel(BakedModel model, BlockState referenceState) {
|
||||||
this(model, referenceState, IDENTITY);
|
this(model, referenceState, IDENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockModel(IBakedModel model, BlockState referenceState, MatrixStack ms) {
|
public BlockModel(BakedModel model, BlockState referenceState, PoseStack ms) {
|
||||||
reader = new BufferBuilderReader(getBufferBuilder(model, referenceState, ms));
|
reader = new BufferBuilderReader(getBufferBuilder(model, referenceState, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,10 +68,10 @@ public class BlockModel implements IModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BufferBuilder getBufferBuilder(IBakedModel model, BlockState referenceState, MatrixStack ms) {
|
public static BufferBuilder getBufferBuilder(BakedModel model, BlockState referenceState, PoseStack ms) {
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
BlockRendererDispatcher dispatcher = mc.getBlockRenderer();
|
BlockRenderDispatcher dispatcher = mc.getBlockRenderer();
|
||||||
BlockModelRenderer blockRenderer = dispatcher.getModelRenderer();
|
ModelBlockRenderer blockRenderer = dispatcher.getModelRenderer();
|
||||||
BufferBuilder builder = new BufferBuilder(512);
|
BufferBuilder builder = new BufferBuilder(512);
|
||||||
|
|
||||||
// BakedQuadWrapper quadReader = new BakedQuadWrapper();
|
// BakedQuadWrapper quadReader = new BakedQuadWrapper();
|
||||||
|
@ -81,7 +81,7 @@ 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, DefaultVertexFormats.BLOCK);
|
builder.begin(GL11.GL_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.renderModel(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;
|
||||||
|
|
|
@ -5,43 +5,43 @@ import static org.lwjgl.opengl.GL11.GL_QUADS;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
import net.minecraft.block.BlockRenderType;
|
import net.minecraft.world.level.block.RenderShape;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.BlockModelRenderer;
|
import net.minecraft.client.renderer.block.ModelBlockRenderer;
|
||||||
import net.minecraft.client.renderer.BlockModelShapes;
|
import net.minecraft.client.renderer.block.BlockModelShaper;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.IBlockDisplayReader;
|
import net.minecraft.world.level.BlockAndTintGetter;
|
||||||
import net.minecraft.world.gen.feature.template.Template;
|
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||||
import net.minecraftforge.client.ForgeHooksClient;
|
import net.minecraftforge.client.ForgeHooksClient;
|
||||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||||
import net.minecraftforge.common.util.Lazy;
|
import net.minecraftforge.common.util.Lazy;
|
||||||
|
|
||||||
public class ModelUtil {
|
public class ModelUtil {
|
||||||
private static final Lazy<BlockModelRenderer> MODEL_RENDERER = Lazy.of(() -> new BlockModelRenderer(Minecraft.getInstance().getBlockColors()));
|
private static final Lazy<ModelBlockRenderer> MODEL_RENDERER = Lazy.of(() -> new ModelBlockRenderer(Minecraft.getInstance().getBlockColors()));
|
||||||
private static final Lazy<BlockModelShapes> BLOCK_MODELS = Lazy.of(() -> Minecraft.getInstance().getModelManager().getBlockModelShaper());
|
private static final Lazy<BlockModelShaper> BLOCK_MODELS = Lazy.of(() -> Minecraft.getInstance().getModelManager().getBlockModelShaper());
|
||||||
|
|
||||||
public static BufferBuilder getBufferBuilderFromTemplate(IBlockDisplayReader renderWorld, RenderType layer, Collection<Template.BlockInfo> blocks) {
|
public static BufferBuilder getBufferBuilderFromTemplate(BlockAndTintGetter renderWorld, RenderType layer, Collection<StructureTemplate.StructureBlockInfo> blocks) {
|
||||||
MatrixStack ms = new MatrixStack();
|
PoseStack ms = new PoseStack();
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize());
|
BufferBuilder builder = new BufferBuilder(DefaultVertexFormat.BLOCK.getIntegerSize());
|
||||||
builder.begin(GL_QUADS, DefaultVertexFormats.BLOCK);
|
builder.begin(GL_QUADS, DefaultVertexFormat.BLOCK);
|
||||||
|
|
||||||
ForgeHooksClient.setRenderLayer(layer);
|
ForgeHooksClient.setRenderLayer(layer);
|
||||||
BlockModelRenderer.enableCaching();
|
ModelBlockRenderer.enableCaching();
|
||||||
for (Template.BlockInfo info : blocks) {
|
for (StructureTemplate.StructureBlockInfo info : blocks) {
|
||||||
BlockState state = info.state;
|
BlockState state = info.state;
|
||||||
|
|
||||||
if (state.getRenderShape() != BlockRenderType.MODEL)
|
if (state.getRenderShape() != RenderShape.MODEL)
|
||||||
continue;
|
continue;
|
||||||
if (!RenderTypeLookup.canRenderInLayer(state, layer))
|
if (!ItemBlockRenderTypes.canRenderInLayer(state, layer))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BlockPos pos = info.pos;
|
BlockPos pos = info.pos;
|
||||||
|
@ -52,7 +52,7 @@ public class ModelUtil {
|
||||||
random, 42, OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE);
|
random, 42, OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE);
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
BlockModelRenderer.clearCache();
|
ModelBlockRenderer.clearCache();
|
||||||
ForgeHooksClient.setRenderLayer(null);
|
ForgeHooksClient.setRenderLayer(null);
|
||||||
|
|
||||||
builder.end();
|
builder.end();
|
||||||
|
|
|
@ -10,10 +10,10 @@ import java.util.Set;
|
||||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.math.vector.Matrix3f;
|
import com.mojang.math.Matrix3f;
|
||||||
import net.minecraft.util.math.vector.Quaternion;
|
import com.mojang.math.Quaternion;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import com.mojang.math.Vector3f;
|
||||||
|
|
||||||
public class PartBuilder {
|
public class PartBuilder {
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.jozufozu.flywheel.core.model;
|
package com.jozufozu.flywheel.core.model;
|
||||||
|
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import com.mojang.math.Vector3f;
|
||||||
|
|
||||||
public class Readable {
|
public class Readable {
|
||||||
public static class ModelBox {
|
public static class ModelBox {
|
||||||
|
|
|
@ -9,14 +9,14 @@ import com.jozufozu.flywheel.util.BufferBuilderReader;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.world.IBlockDisplayReader;
|
import net.minecraft.world.level.BlockAndTintGetter;
|
||||||
import net.minecraft.world.gen.feature.template.Template;
|
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||||
|
|
||||||
public class WorldModel implements IModel {
|
public class WorldModel implements IModel {
|
||||||
|
|
||||||
private final BufferBuilderReader reader;
|
private final BufferBuilderReader reader;
|
||||||
|
|
||||||
public WorldModel(IBlockDisplayReader renderWorld, RenderType layer, Collection<Template.BlockInfo> blocks) {
|
public WorldModel(BlockAndTintGetter renderWorld, RenderType layer, Collection<StructureTemplate.StructureBlockInfo> blocks) {
|
||||||
reader = new BufferBuilderReader(ModelUtil.getBufferBuilderFromTemplate(renderWorld, layer, blocks));
|
reader = new BufferBuilderReader(ModelUtil.getBufferBuilderFromTemplate(renderWorld, layer, blocks));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||||
import com.jozufozu.flywheel.core.shader.extension.IExtensionInstance;
|
import com.jozufozu.flywheel.core.shader.extension.IExtensionInstance;
|
||||||
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A shader program that be arbitrarily "extended". This class can take in any number of program extensions, and
|
* A shader program that be arbitrarily "extended". This class can take in any number of program extensions, and
|
||||||
|
|
|
@ -6,7 +6,7 @@ import com.jozufozu.flywheel.Flywheel;
|
||||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||||
import com.jozufozu.flywheel.core.shader.extension.IExtensionInstance;
|
import com.jozufozu.flywheel.core.shader.extension.IExtensionInstance;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public abstract class FogMode {
|
public abstract class FogMode {
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import com.jozufozu.flywheel.core.shader.extension.IExtensionInstance;
|
||||||
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
||||||
import com.jozufozu.flywheel.core.shader.extension.UnitExtensionInstance;
|
import com.jozufozu.flywheel.core.shader.extension.UnitExtensionInstance;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public enum WorldFog implements IProgramExtension {
|
public enum WorldFog implements IProgramExtension {
|
||||||
NONE("none", UnitExtensionInstance::new),
|
NONE("none", UnitExtensionInstance::new),
|
||||||
|
|
|
@ -9,10 +9,10 @@ import java.util.List;
|
||||||
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
||||||
import com.jozufozu.flywheel.util.AnimationTickHolder;
|
import com.jozufozu.flywheel.util.AnimationTickHolder;
|
||||||
|
|
||||||
import net.minecraft.client.MainWindow;
|
import com.mojang.blaze3d.platform.Window;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
import com.mojang.math.Matrix4f;
|
||||||
|
|
||||||
public class WorldProgram extends ExtensibleGlProgram {
|
public class WorldProgram extends ExtensibleGlProgram {
|
||||||
protected final int uTime = getUniformLocation("uTime");
|
protected final int uTime = getUniformLocation("uTime");
|
||||||
|
@ -45,7 +45,7 @@ public class WorldProgram extends ExtensibleGlProgram {
|
||||||
public void uploadWindowSize() {
|
public void uploadWindowSize() {
|
||||||
if (uWindowSize < 0) return;
|
if (uWindowSize < 0) return;
|
||||||
|
|
||||||
MainWindow window = Minecraft.getInstance().getWindow();
|
Window window = Minecraft.getInstance().getWindow();
|
||||||
|
|
||||||
int height = window.getScreenHeight();
|
int height = window.getScreenHeight();
|
||||||
int width = window.getScreenWidth();
|
int width = window.getScreenWidth();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.jozufozu.flywheel.core.shader.extension;
|
package com.jozufozu.flywheel.core.shader.extension;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public interface IExtensionInstance {
|
public interface IExtensionInstance {
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.SpecMetaRegistry;
|
||||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A factory interface for creating {@link IExtensionInstance}s. These are what end up being passed in
|
* A factory interface for creating {@link IExtensionInstance}s. These are what end up being passed in
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.jozufozu.flywheel.core.shader.extension;
|
||||||
import com.jozufozu.flywheel.Flywheel;
|
import com.jozufozu.flywheel.Flywheel;
|
||||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class UnitExtensionInstance implements IExtensionInstance {
|
public class UnitExtensionInstance implements IExtensionInstance {
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.jozufozu.flywheel.core.shader.gamestate;
|
||||||
import com.jozufozu.flywheel.Flywheel;
|
import com.jozufozu.flywheel.Flywheel;
|
||||||
import com.jozufozu.flywheel.core.shader.GlFog;
|
import com.jozufozu.flywheel.core.shader.GlFog;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class FogStateProvider implements IGameStateProvider {
|
public class FogStateProvider implements IGameStateProvider {
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.jozufozu.flywheel.core.shader.gamestate;
|
||||||
import com.jozufozu.flywheel.backend.SpecMetaRegistry;
|
import com.jozufozu.flywheel.backend.SpecMetaRegistry;
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public interface IGameStateProvider {
|
public interface IGameStateProvider {
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.jozufozu.flywheel.Flywheel;
|
||||||
import com.jozufozu.flywheel.config.FlwConfig;
|
import com.jozufozu.flywheel.config.FlwConfig;
|
||||||
import com.jozufozu.flywheel.core.shader.spec.IBooleanStateProvider;
|
import com.jozufozu.flywheel.core.shader.spec.IBooleanStateProvider;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class NormalDebugStateProvider implements IBooleanStateProvider {
|
public class NormalDebugStateProvider implements IBooleanStateProvider {
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.jozufozu.flywheel.core.shader.spec;
|
||||||
import com.jozufozu.flywheel.core.shader.gamestate.IGameStateProvider;
|
import com.jozufozu.flywheel.core.shader.gamestate.IGameStateProvider;
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class BooleanGameStateCondition implements IGameStateCondition {
|
public class BooleanGameStateCondition implements IGameStateCondition {
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.core.shader.spec;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.core.shader.gamestate.IGameStateProvider;
|
import com.jozufozu.flywheel.core.shader.gamestate.IGameStateProvider;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public interface IGameStateCondition {
|
public interface IGameStateCondition {
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import com.jozufozu.flywheel.backend.source.SourceFile;
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object describing a shader program that can be loaded by flywheel.
|
* An object describing a shader program that can be loaded by flywheel.
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.jozufozu.flywheel.core.shader.gamestate.IGameStateProvider;
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public class SpecificValueCondition implements IGameStateCondition {
|
public class SpecificValueCondition implements IGameStateCondition {
|
||||||
|
|
||||||
|
|
|
@ -1,35 +1,35 @@
|
||||||
package com.jozufozu.flywheel.event;
|
package com.jozufozu.flywheel.event;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
import net.minecraft.client.Camera;
|
||||||
import net.minecraft.client.renderer.culling.ClippingHelper;
|
import net.minecraft.client.renderer.culling.Frustum;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
|
||||||
public class BeginFrameEvent extends Event {
|
public class BeginFrameEvent extends Event {
|
||||||
private final ClientWorld world;
|
private final ClientLevel world;
|
||||||
private final ActiveRenderInfo info;
|
private final Camera info;
|
||||||
private final ClippingHelper clippingHelper;
|
private final Frustum clippingHelper;
|
||||||
|
|
||||||
public BeginFrameEvent(ClientWorld world, ActiveRenderInfo info, ClippingHelper clippingHelper) {
|
public BeginFrameEvent(ClientLevel world, Camera info, Frustum clippingHelper) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
this.clippingHelper = clippingHelper;
|
this.clippingHelper = clippingHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientWorld getWorld() {
|
public ClientLevel getWorld() {
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActiveRenderInfo getInfo() {
|
public Camera getInfo() {
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClippingHelper getClippingHelper() {
|
public Frustum getClippingHelper() {
|
||||||
return clippingHelper;
|
return clippingHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3d getCameraPos() {
|
public Vec3 getCameraPos() {
|
||||||
return info.getPosition();
|
return info.getPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
|
||||||
import com.jozufozu.flywheel.light.LightUpdater;
|
import com.jozufozu.flywheel.light.LightUpdater;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
|
@ -40,10 +40,10 @@ public class ForgeEvents {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onLoadWorld(WorldEvent.Load event) {
|
public static void onLoadWorld(WorldEvent.Load event) {
|
||||||
IWorld world = event.getWorld();
|
LevelAccessor world = event.getWorld();
|
||||||
|
|
||||||
if (Backend.isFlywheelWorld(world)) {
|
if (Backend.isFlywheelWorld(world)) {
|
||||||
InstancedRenderDispatcher.loadAllInWorld((ClientWorld) world);
|
InstancedRenderDispatcher.loadAllInWorld((ClientLevel) world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,18 +2,18 @@ package com.jozufozu.flywheel.event;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
|
||||||
public class ReloadRenderersEvent extends Event {
|
public class ReloadRenderersEvent extends Event {
|
||||||
private final ClientWorld world;
|
private final ClientLevel world;
|
||||||
|
|
||||||
public ReloadRenderersEvent(ClientWorld world) {
|
public ReloadRenderersEvent(ClientLevel world) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public ClientWorld getWorld() {
|
public ClientLevel getWorld() {
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,26 +4,26 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.state.RenderLayer;
|
import com.jozufozu.flywheel.backend.state.RenderLayer;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.RenderTypeBuffers;
|
import net.minecraft.client.renderer.RenderBuffers;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
import com.mojang.math.Matrix4f;
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
|
||||||
public class RenderLayerEvent extends Event {
|
public class RenderLayerEvent extends Event {
|
||||||
private final ClientWorld world;
|
private final ClientLevel world;
|
||||||
public final RenderType type;
|
public final RenderType type;
|
||||||
public final MatrixStack stack;
|
public final PoseStack stack;
|
||||||
public final Matrix4f viewProjection;
|
public final Matrix4f viewProjection;
|
||||||
public final RenderTypeBuffers buffers;
|
public final RenderBuffers buffers;
|
||||||
public final double camX;
|
public final double camX;
|
||||||
public final double camY;
|
public final double camY;
|
||||||
public final double camZ;
|
public final double camZ;
|
||||||
public final RenderLayer layer;
|
public final RenderLayer layer;
|
||||||
|
|
||||||
public RenderLayerEvent(ClientWorld world, RenderType type, MatrixStack stack, RenderTypeBuffers buffers, double camX, double camY, double camZ) {
|
public RenderLayerEvent(ClientLevel world, RenderType type, PoseStack stack, RenderBuffers buffers, double camX, double camY, double camZ) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
|
@ -47,7 +47,7 @@ public class RenderLayerEvent extends Event {
|
||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientWorld getWorld() {
|
public ClientLevel getWorld() {
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,28 +3,28 @@ package com.jozufozu.flywheel.light;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.IBlockDisplayReader;
|
import net.minecraft.world.level.BlockAndTintGetter;
|
||||||
import net.minecraft.world.LightType;
|
import net.minecraft.world.level.LightLayer;
|
||||||
|
|
||||||
public class BasicProvider implements LightProvider {
|
public class BasicProvider implements LightProvider {
|
||||||
|
|
||||||
private static final Map<IBlockDisplayReader, BasicProvider> wrappers = new WeakHashMap<>();
|
private static final Map<BlockAndTintGetter, BasicProvider> wrappers = new WeakHashMap<>();
|
||||||
|
|
||||||
public static BasicProvider get(IBlockDisplayReader world) {
|
public static BasicProvider get(BlockAndTintGetter world) {
|
||||||
return wrappers.computeIfAbsent(world, BasicProvider::new);
|
return wrappers.computeIfAbsent(world, BasicProvider::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final BlockPos.Mutable pos = new BlockPos.Mutable();
|
private final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
|
||||||
|
|
||||||
private final IBlockDisplayReader reader;
|
private final BlockAndTintGetter reader;
|
||||||
|
|
||||||
public BasicProvider(IBlockDisplayReader reader) {
|
public BasicProvider(BlockAndTintGetter reader) {
|
||||||
this.reader = reader;
|
this.reader = reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLight(LightType type, int x, int y, int z) {
|
public int getLight(LightLayer type, int x, int y, int z) {
|
||||||
return reader.getBrightness(type, pos.set(x, y, z));
|
return reader.getBrightness(type, pos.set(x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import com.jozufozu.flywheel.backend.gl.GlTexture;
|
||||||
import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
|
import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
|
||||||
import com.jozufozu.flywheel.backend.gl.versioned.RGPixelFormat;
|
import com.jozufozu.flywheel.backend.gl.versioned.RGPixelFormat;
|
||||||
|
|
||||||
import net.minecraft.world.LightType;
|
import net.minecraft.world.level.LightLayer;
|
||||||
|
|
||||||
public class GPULightVolume extends LightVolume {
|
public class GPULightVolume extends LightVolume {
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ public class GPULightVolume extends LightVolume {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLightUpdate(LightProvider world, LightType type, ImmutableBox changedVolume) {
|
public void onLightUpdate(LightProvider world, LightLayer type, ImmutableBox changedVolume) {
|
||||||
super.onLightUpdate(world, type, changedVolume);
|
super.onLightUpdate(world, type, changedVolume);
|
||||||
bufferDirty = true;
|
bufferDirty = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,11 @@ package com.jozufozu.flywheel.light;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.util.RenderUtil;
|
import com.jozufozu.flywheel.util.RenderUtil;
|
||||||
|
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.SectionPos;
|
import net.minecraft.core.SectionPos;
|
||||||
import net.minecraft.util.math.vector.Vector3i;
|
import net.minecraft.core.Vec3i;
|
||||||
|
|
||||||
public class GridAlignedBB implements ImmutableBox {
|
public class GridAlignedBB implements ImmutableBox {
|
||||||
private int minX;
|
private int minX;
|
||||||
|
@ -33,7 +33,7 @@ public class GridAlignedBB implements ImmutableBox {
|
||||||
return new GridAlignedBB(-radius, -radius, -radius, radius + 1, radius + 1, radius + 1);
|
return new GridAlignedBB(-radius, -radius, -radius, radius + 1, radius + 1, radius + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GridAlignedBB from(AxisAlignedBB aabb) {
|
public static GridAlignedBB from(AABB aabb) {
|
||||||
int minX = (int) Math.floor(aabb.minX);
|
int minX = (int) Math.floor(aabb.minX);
|
||||||
int minY = (int) Math.floor(aabb.minY);
|
int minY = (int) Math.floor(aabb.minY);
|
||||||
int minZ = (int) Math.floor(aabb.minZ);
|
int minZ = (int) Math.floor(aabb.minZ);
|
||||||
|
@ -77,7 +77,7 @@ public class GridAlignedBB implements ImmutableBox {
|
||||||
this.maxZ = maxZ;
|
this.maxZ = maxZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void translate(Vector3i by) {
|
public void translate(Vec3i by) {
|
||||||
translate(by.getX(), by.getY(), by.getZ());
|
translate(by.getX(), by.getY(), by.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class GridAlignedBB implements ImmutableBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mirrorAbout(Direction.Axis axis) {
|
public void mirrorAbout(Direction.Axis axis) {
|
||||||
Vector3i axisVec = Direction.get(Direction.AxisDirection.POSITIVE, axis)
|
Vec3i axisVec = Direction.get(Direction.AxisDirection.POSITIVE, axis)
|
||||||
.getNormal();
|
.getNormal();
|
||||||
int flipX = axisVec.getX() - 1;
|
int flipX = axisVec.getX() - 1;
|
||||||
int flipY = axisVec.getY() - 1;
|
int flipY = axisVec.getY() - 1;
|
||||||
|
@ -176,7 +176,7 @@ public class GridAlignedBB implements ImmutableBox {
|
||||||
maxZ = Math.max(this.maxZ, other.getMaxZ());
|
maxZ = Math.max(this.maxZ, other.getMaxZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unionAssign(AxisAlignedBB other) {
|
public void unionAssign(AABB other) {
|
||||||
minX = Math.min(this.minX, (int) Math.floor(other.minX));
|
minX = Math.min(this.minX, (int) Math.floor(other.minX));
|
||||||
minY = Math.min(this.minY, (int) Math.floor(other.minY));
|
minY = Math.min(this.minY, (int) Math.floor(other.minY));
|
||||||
minZ = Math.min(this.minZ, (int) Math.floor(other.minZ));
|
minZ = Math.min(this.minZ, (int) Math.floor(other.minZ));
|
||||||
|
@ -185,7 +185,7 @@ public class GridAlignedBB implements ImmutableBox {
|
||||||
maxZ = Math.max(this.maxZ, (int) Math.ceil(other.maxZ));
|
maxZ = Math.max(this.maxZ, (int) Math.ceil(other.maxZ));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assign(AxisAlignedBB other) {
|
public void assign(AABB other) {
|
||||||
minX = (int) Math.floor(other.minX);
|
minX = (int) Math.floor(other.minX);
|
||||||
minY = (int) Math.floor(other.minY);
|
minY = (int) Math.floor(other.minY);
|
||||||
minZ = (int) Math.floor(other.minZ);
|
minZ = (int) Math.floor(other.minZ);
|
||||||
|
@ -294,11 +294,11 @@ public class GridAlignedBB implements ImmutableBox {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GridAlignedBB setMax(Vector3i v) {
|
public GridAlignedBB setMax(Vec3i v) {
|
||||||
return setMax(v.getX(), v.getY(), v.getZ());
|
return setMax(v.getX(), v.getY(), v.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public GridAlignedBB setMin(Vector3i v) {
|
public GridAlignedBB setMin(Vec3i v) {
|
||||||
return setMin(v.getX(), v.getY(), v.getZ());
|
return setMin(v.getX(), v.getY(), v.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ public class GridAlignedBB implements ImmutableBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean sameAs(AxisAlignedBB other) {
|
public boolean sameAs(AABB other) {
|
||||||
return minX == Math.floor(other.minX)
|
return minX == Math.floor(other.minX)
|
||||||
&& minY == Math.floor(other.minY)
|
&& minY == Math.floor(other.minY)
|
||||||
&& minZ == Math.floor(other.minZ)
|
&& minZ == Math.floor(other.minZ)
|
||||||
|
@ -398,8 +398,8 @@ public class GridAlignedBB implements ImmutableBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB toAABB() {
|
public AABB toAABB() {
|
||||||
return new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
|
return new AABB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.jozufozu.flywheel.light;
|
package com.jozufozu.flywheel.light;
|
||||||
|
|
||||||
import net.minecraft.world.LightType;
|
import net.minecraft.world.level.LightLayer;
|
||||||
|
|
||||||
public interface ILightUpdateListener {
|
public interface ILightUpdateListener {
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ public interface ILightUpdateListener {
|
||||||
/**
|
/**
|
||||||
* Called when a light updates in a chunk the implementor cares about.
|
* Called when a light updates in a chunk the implementor cares about.
|
||||||
*/
|
*/
|
||||||
void onLightUpdate(LightProvider world, LightType type, ImmutableBox changed);
|
void onLightUpdate(LightProvider world, LightLayer type, ImmutableBox changed);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the server sends light data to the client.
|
* Called when the server sends light data to the client.
|
||||||
|
@ -20,8 +20,8 @@ public interface ILightUpdateListener {
|
||||||
default void onLightPacket(LightProvider world, int chunkX, int chunkZ) {
|
default void onLightPacket(LightProvider world, int chunkX, int chunkZ) {
|
||||||
GridAlignedBB changedVolume = GridAlignedBB.from(chunkX, chunkZ);
|
GridAlignedBB changedVolume = GridAlignedBB.from(chunkX, chunkZ);
|
||||||
|
|
||||||
onLightUpdate(world, LightType.BLOCK, changedVolume);
|
onLightUpdate(world, LightLayer.BLOCK, changedVolume);
|
||||||
|
|
||||||
onLightUpdate(world, LightType.SKY, changedVolume);
|
onLightUpdate(world, LightLayer.SKY, changedVolume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.light;
|
||||||
|
|
||||||
import static com.jozufozu.flywheel.util.RenderUtil.isPowerOf2;
|
import static com.jozufozu.flywheel.util.RenderUtil.isPowerOf2;
|
||||||
|
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.world.phys.AABB;
|
||||||
|
|
||||||
public interface ImmutableBox {
|
public interface ImmutableBox {
|
||||||
int getMinX();
|
int getMinX();
|
||||||
|
@ -42,7 +42,7 @@ public interface ImmutableBox {
|
||||||
return getMinX() == other.getMinX() && getMinY() == other.getMinY() && getMinZ() == other.getMinZ() && getMaxX() == other.getMaxX() && getMaxY() == other.getMaxY() && getMaxZ() == other.getMaxZ();
|
return getMinX() == other.getMinX() && getMinY() == other.getMinY() && getMinZ() == other.getMinZ() && getMaxX() == other.getMaxX() && getMaxY() == other.getMaxY() && getMaxZ() == other.getMaxZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean sameAs(AxisAlignedBB other) {
|
default boolean sameAs(AABB other) {
|
||||||
return getMinX() == Math.floor(other.minX)
|
return getMinX() == Math.floor(other.minX)
|
||||||
&& getMinY() == Math.floor(other.minY)
|
&& getMinY() == Math.floor(other.minY)
|
||||||
&& getMinZ() == Math.floor(other.minZ)
|
&& getMinZ() == Math.floor(other.minZ)
|
||||||
|
@ -119,8 +119,8 @@ public interface ImmutableBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default AxisAlignedBB toAABB() {
|
default AABB toAABB() {
|
||||||
return new AxisAlignedBB(getMinX(), getMinY(), getMinZ(), getMaxX(), getMaxY(), getMaxZ());
|
return new AABB(getMinX(), getMinY(), getMinZ(), getMaxX(), getMaxY(), getMaxZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
default GridAlignedBB copy() {
|
default GridAlignedBB copy() {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package com.jozufozu.flywheel.light;
|
package com.jozufozu.flywheel.light;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
import net.minecraft.world.LightType;
|
import net.minecraft.world.level.LightLayer;
|
||||||
|
|
||||||
public interface LightProvider {
|
public interface LightProvider {
|
||||||
int getLight(LightType type, int x, int y, int z);
|
int getLight(LightLayer type, int x, int y, int z);
|
||||||
|
|
||||||
default int getPackedLight(int x, int y, int z) {
|
default int getPackedLight(int x, int y, int z) {
|
||||||
return LightTexture.pack(getLight(LightType.BLOCK, x, y, z), getLight(LightType.SKY, x, y, z));
|
return LightTexture.pack(getLight(LightLayer.BLOCK, x, y, z), getLight(LightLayer.SKY, x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,18 +8,18 @@ import java.util.stream.Stream;
|
||||||
import com.jozufozu.flywheel.util.WeakHashSet;
|
import com.jozufozu.flywheel.util.WeakHashSet;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.SectionPos;
|
import net.minecraft.core.SectionPos;
|
||||||
import net.minecraft.world.IBlockDisplayReader;
|
import net.minecraft.world.level.BlockAndTintGetter;
|
||||||
import net.minecraft.world.LightType;
|
import net.minecraft.world.level.LightLayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keeps track of what chunks/sections each listener is in, so we can update exactly what needs to be updated.
|
* Keeps track of what chunks/sections each listener is in, so we can update exactly what needs to be updated.
|
||||||
*/
|
*/
|
||||||
public class LightUpdater {
|
public class LightUpdater {
|
||||||
|
|
||||||
private static final Map<IBlockDisplayReader, LightUpdater> light = new HashMap<>();
|
private static final Map<BlockAndTintGetter, LightUpdater> light = new HashMap<>();
|
||||||
public static LightUpdater get(IBlockDisplayReader world) {
|
public static LightUpdater get(BlockAndTintGetter world) {
|
||||||
return light.computeIfAbsent(world, LightUpdater::new);
|
return light.computeIfAbsent(world, LightUpdater::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public class LightUpdater {
|
||||||
private final WeakContainmentMultiMap<ILightUpdateListener> sections = new WeakContainmentMultiMap<>();
|
private final WeakContainmentMultiMap<ILightUpdateListener> sections = new WeakContainmentMultiMap<>();
|
||||||
private final WeakContainmentMultiMap<ILightUpdateListener> chunks = new WeakContainmentMultiMap<>();
|
private final WeakContainmentMultiMap<ILightUpdateListener> chunks = new WeakContainmentMultiMap<>();
|
||||||
|
|
||||||
public LightUpdater(IBlockDisplayReader world) {
|
public LightUpdater(BlockAndTintGetter world) {
|
||||||
provider = BasicProvider.get(world);
|
provider = BasicProvider.get(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public class LightUpdater {
|
||||||
* @param type The type of light that changed.
|
* @param type The type of light that changed.
|
||||||
* @param sectionPos A long representing the section position where light changed.
|
* @param sectionPos A long representing the section position where light changed.
|
||||||
*/
|
*/
|
||||||
public void onLightUpdate(LightType type, long sectionPos) {
|
public void onLightUpdate(LightLayer type, long sectionPos) {
|
||||||
Set<ILightUpdateListener> set = sections.get(sectionPos);
|
Set<ILightUpdateListener> set = sections.get(sectionPos);
|
||||||
|
|
||||||
if (set == null || set.isEmpty()) return;
|
if (set == null || set.isEmpty()) return;
|
||||||
|
|
|
@ -4,8 +4,8 @@ import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import org.lwjgl.system.MemoryUtil;
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.LightType;
|
import net.minecraft.world.level.LightLayer;
|
||||||
|
|
||||||
public class LightVolume implements ImmutableBox, ILightUpdateListener {
|
public class LightVolume implements ImmutableBox, ILightUpdateListener {
|
||||||
|
|
||||||
|
@ -66,15 +66,15 @@ public class LightVolume implements ImmutableBox, ILightUpdateListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLightUpdate(LightProvider world, LightType type, ImmutableBox changedVolume) {
|
public void onLightUpdate(LightProvider world, LightLayer type, ImmutableBox changedVolume) {
|
||||||
if (lightData == null) return;
|
if (lightData == null) return;
|
||||||
|
|
||||||
GridAlignedBB vol = changedVolume.copy();
|
GridAlignedBB vol = changedVolume.copy();
|
||||||
if (!vol.intersects(getVolume())) return;
|
if (!vol.intersects(getVolume())) return;
|
||||||
vol.intersectAssign(getVolume()); // compute the region contained by us that has dirty lighting data.
|
vol.intersectAssign(getVolume()); // compute the region contained by us that has dirty lighting data.
|
||||||
|
|
||||||
if (type == LightType.BLOCK) copyBlock(world, vol);
|
if (type == LightLayer.BLOCK) copyBlock(world, vol);
|
||||||
else if (type == LightType.SKY) copySky(world, vol);
|
else if (type == LightLayer.SKY) copySky(world, vol);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,8 +101,8 @@ public class LightVolume implements ImmutableBox, ILightUpdateListener {
|
||||||
int shiftZ = box.getMinZ();
|
int shiftZ = box.getMinZ();
|
||||||
|
|
||||||
box.forEachContained((x, y, z) -> {
|
box.forEachContained((x, y, z) -> {
|
||||||
int blockLight = world.getLight(LightType.BLOCK, x, y, z);
|
int blockLight = world.getLight(LightLayer.BLOCK, x, y, z);
|
||||||
int skyLight = world.getLight(LightType.SKY, x, y, z);
|
int skyLight = world.getLight(LightLayer.SKY, x, y, z);
|
||||||
|
|
||||||
writeLight(x - shiftX, y - shiftY, z - shiftZ, blockLight, skyLight);
|
writeLight(x - shiftX, y - shiftY, z - shiftZ, blockLight, skyLight);
|
||||||
});
|
});
|
||||||
|
@ -119,7 +119,7 @@ public class LightVolume implements ImmutableBox, ILightUpdateListener {
|
||||||
int zShift = box.getMinZ();
|
int zShift = box.getMinZ();
|
||||||
|
|
||||||
worldVolume.forEachContained((x, y, z) -> {
|
worldVolume.forEachContained((x, y, z) -> {
|
||||||
int light = world.getLight(LightType.BLOCK, x, y, z);
|
int light = world.getLight(LightLayer.BLOCK, x, y, z);
|
||||||
|
|
||||||
writeBlock(x - xShift, y - yShift, z - zShift, light);
|
writeBlock(x - xShift, y - yShift, z - zShift, light);
|
||||||
});
|
});
|
||||||
|
@ -136,7 +136,7 @@ public class LightVolume implements ImmutableBox, ILightUpdateListener {
|
||||||
int zShift = box.getMinZ();
|
int zShift = box.getMinZ();
|
||||||
|
|
||||||
worldVolume.forEachContained((x, y, z) -> {
|
worldVolume.forEachContained((x, y, z) -> {
|
||||||
int light = world.getLight(LightType.SKY, x, y, z);
|
int light = world.getLight(LightLayer.SKY, x, y, z);
|
||||||
|
|
||||||
writeSky(x - xShift, y - yShift, z - zShift, light);
|
writeSky(x - xShift, y - yShift, z - zShift, light);
|
||||||
});
|
});
|
||||||
|
@ -148,7 +148,7 @@ public class LightVolume implements ImmutableBox, ILightUpdateListener {
|
||||||
* @param worldVolume the region in the world to copy data from.
|
* @param worldVolume the region in the world to copy data from.
|
||||||
*/
|
*/
|
||||||
public void copyLight(LightProvider world, ImmutableBox worldVolume) {
|
public void copyLight(LightProvider world, ImmutableBox worldVolume) {
|
||||||
BlockPos.Mutable pos = new BlockPos.Mutable();
|
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
|
||||||
|
|
||||||
int xShift = box.getMinX();
|
int xShift = box.getMinX();
|
||||||
int yShift = box.getMinY();
|
int yShift = box.getMinY();
|
||||||
|
@ -157,8 +157,8 @@ public class LightVolume implements ImmutableBox, ILightUpdateListener {
|
||||||
worldVolume.forEachContained((x, y, z) -> {
|
worldVolume.forEachContained((x, y, z) -> {
|
||||||
pos.set(x, y, z);
|
pos.set(x, y, z);
|
||||||
|
|
||||||
int block = world.getLight(LightType.BLOCK, x, y, z);
|
int block = world.getLight(LightLayer.BLOCK, x, y, z);
|
||||||
int sky = world.getLight(LightType.SKY, x, y, z);
|
int sky = world.getLight(LightLayer.SKY, x, y, z);
|
||||||
|
|
||||||
writeLight(x - xShift, y - yShift, z - zShift, block, sky);
|
writeLight(x - xShift, y - yShift, z - zShift, block, sky);
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,17 +12,17 @@ import com.google.common.collect.Lists;
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.WorldRenderer;
|
import net.minecraft.client.renderer.LevelRenderer;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.util.ClassInheritanceMultiMap;
|
import net.minecraft.util.ClassInstanceMultiMap;
|
||||||
|
|
||||||
@Mixin(WorldRenderer.class)
|
@Mixin(LevelRenderer.class)
|
||||||
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/world/ClientWorld;entitiesForRendering()Ljava/lang/Iterable;"))
|
||||||
private Iterable<Entity> filterEntities(ClientWorld world) {
|
private Iterable<Entity> filterEntities(ClientLevel world) {
|
||||||
Iterable<Entity> entities = world.entitiesForRendering();
|
Iterable<Entity> entities = world.entitiesForRendering();
|
||||||
if (Backend.getInstance()
|
if (Backend.getInstance()
|
||||||
.canUseInstancing()) {
|
.canUseInstancing()) {
|
||||||
|
@ -39,7 +39,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/ClassInheritanceMultiMap;iterator()Ljava/util/Iterator;"))
|
||||||
private Iterator<Entity> filterEntitiesOF(ClassInheritanceMultiMap<Entity> classInheritanceMultiMap) {
|
private Iterator<Entity> filterEntitiesOF(ClassInstanceMultiMap<Entity> classInheritanceMultiMap) {
|
||||||
if (Backend.getInstance()
|
if (Backend.getInstance()
|
||||||
.canUseInstancing()) {
|
.canUseInstancing()) {
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher;
|
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
@ -26,10 +26,10 @@ public class CancelTileEntityRenderMixin {
|
||||||
* doing unnecessary light lookups and frustum checks.
|
* doing unnecessary light lookups and frustum checks.
|
||||||
*/
|
*/
|
||||||
@Inject(at = @At("RETURN"), method = "getRenderableBlockEntities", cancellable = true)
|
@Inject(at = @At("RETURN"), method = "getRenderableBlockEntities", cancellable = true)
|
||||||
private void noRenderInstancedTiles(CallbackInfoReturnable<List<TileEntity>> cir) {
|
private void noRenderInstancedTiles(CallbackInfoReturnable<List<BlockEntity>> cir) {
|
||||||
if (Backend.getInstance()
|
if (Backend.getInstance()
|
||||||
.canUseInstancing()) {
|
.canUseInstancing()) {
|
||||||
List<TileEntity> tiles = cir.getReturnValue();
|
List<BlockEntity> tiles = cir.getReturnValue();
|
||||||
|
|
||||||
InstancedRenderRegistry r = InstancedRenderRegistry.getInstance();
|
InstancedRenderRegistry r = InstancedRenderRegistry.getInstance();
|
||||||
tiles.removeIf(r::shouldSkipRender);
|
tiles.removeIf(r::shouldSkipRender);
|
||||||
|
|
|
@ -12,34 +12,34 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
|
|
||||||
import net.minecraft.client.multiplayer.ClientChunkProvider;
|
import net.minecraft.client.multiplayer.ClientChunkCache;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.biome.BiomeContainer;
|
import net.minecraft.world.level.chunk.ChunkBiomeContainer;
|
||||||
import net.minecraft.world.chunk.AbstractChunkProvider;
|
import net.minecraft.world.level.chunk.ChunkSource;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.level.chunk.LevelChunk;
|
||||||
import net.minecraft.world.chunk.ChunkStatus;
|
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||||
import net.minecraft.world.chunk.IChunk;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
|
|
||||||
@Mixin(ClientChunkProvider.class)
|
@Mixin(ClientChunkCache.class)
|
||||||
public abstract class FastChunkProviderMixin extends AbstractChunkProvider {
|
public abstract class FastChunkProviderMixin extends ChunkSource {
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
@Final
|
@Final
|
||||||
private ClientWorld level;
|
private ClientLevel level;
|
||||||
@Unique
|
@Unique
|
||||||
private int lastX;
|
private int lastX;
|
||||||
@Unique
|
@Unique
|
||||||
private int lastZ;
|
private int lastZ;
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private IChunk lastChunk;
|
private ChunkAccess lastChunk;
|
||||||
|
|
||||||
@Inject(method = "getChunk",
|
@Inject(method = "getChunk",
|
||||||
at = @At("HEAD"),
|
at = @At("HEAD"),
|
||||||
cancellable = true)
|
cancellable = true)
|
||||||
public void returnCachedChunk(int x, int z, ChunkStatus status, boolean create, CallbackInfoReturnable<IChunk> cir) {
|
public void returnCachedChunk(int x, int z, ChunkStatus status, boolean create, CallbackInfoReturnable<ChunkAccess> cir) {
|
||||||
if (Backend.getInstance().chunkCachingEnabled && status.isOrAfter(ChunkStatus.FULL)) {
|
if (Backend.getInstance().chunkCachingEnabled && status.isOrAfter(ChunkStatus.FULL)) {
|
||||||
synchronized (level) {
|
synchronized (level) {
|
||||||
if (lastChunk != null && x == lastX && z == lastZ) {
|
if (lastChunk != null && x == lastX && z == lastZ) {
|
||||||
|
@ -51,7 +51,7 @@ public abstract class FastChunkProviderMixin extends AbstractChunkProvider {
|
||||||
|
|
||||||
@Inject(method = "getChunk",
|
@Inject(method = "getChunk",
|
||||||
at = @At("RETURN"))
|
at = @At("RETURN"))
|
||||||
public void cacheChunk(int x, int z, ChunkStatus status, boolean create, CallbackInfoReturnable<IChunk> cir) {
|
public void cacheChunk(int x, int z, ChunkStatus status, boolean create, CallbackInfoReturnable<ChunkAccess> cir) {
|
||||||
if (Backend.getInstance().chunkCachingEnabled && status.isOrAfter(ChunkStatus.FULL)) {
|
if (Backend.getInstance().chunkCachingEnabled && status.isOrAfter(ChunkStatus.FULL)) {
|
||||||
synchronized (level) {
|
synchronized (level) {
|
||||||
lastChunk = cir.getReturnValue();
|
lastChunk = cir.getReturnValue();
|
||||||
|
@ -71,7 +71,7 @@ public abstract class FastChunkProviderMixin extends AbstractChunkProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "replaceWithPacketData", at = @At("HEAD"))
|
@Inject(method = "replaceWithPacketData", at = @At("HEAD"))
|
||||||
public void invalidateOnPacket(int x, int z, BiomeContainer p_228313_3_, PacketBuffer p_228313_4_, CompoundNBT p_228313_5_, int p_228313_6_, boolean p_228313_7_, CallbackInfoReturnable<Chunk> cir) {
|
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) {
|
||||||
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;
|
||||||
|
@ -80,7 +80,7 @@ public abstract class FastChunkProviderMixin extends AbstractChunkProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "isTickingChunk", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientChunkProvider;hasChunk(II)Z"))
|
@Redirect(method = "isTickingChunk", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientChunkProvider;hasChunk(II)Z"))
|
||||||
public boolean redirectTicking(ClientChunkProvider clientChunkProvider, int x, int z) {
|
public boolean redirectTicking(ClientChunkCache clientChunkProvider, int x, int z) {
|
||||||
if (Backend.getInstance().chunkCachingEnabled) {
|
if (Backend.getInstance().chunkCachingEnabled) {
|
||||||
synchronized (level) {
|
synchronized (level) {
|
||||||
if (lastChunk != null && x == lastX && z == lastZ) return true;
|
if (lastChunk != null && x == lastX && z == lastZ) return true;
|
||||||
|
|
|
@ -5,23 +5,23 @@ 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 com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
import net.minecraft.client.Camera;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
import net.minecraft.client.renderer.WorldRenderer;
|
import net.minecraft.client.renderer.LevelRenderer;
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
import com.mojang.math.Matrix4f;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@Mixin(WorldRenderer.class)
|
@Mixin(LevelRenderer.class)
|
||||||
public class FixFabulousDepthMixin {
|
public class FixFabulousDepthMixin {
|
||||||
|
|
||||||
@Inject(method = "renderLevel", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/client/shader/ShaderGroup;process(F)V"))
|
@Inject(method = "renderLevel", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/client/shader/ShaderGroup;process(F)V"))
|
||||||
private void disableTransparencyShaderDepth(MatrixStack p_228426_1_, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, ActiveRenderInfo p_228426_6_, GameRenderer p_228426_7_, LightTexture p_228426_8_, Matrix4f p_228426_9_, CallbackInfo ci) {
|
private void disableTransparencyShaderDepth(PoseStack p_228426_1_, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, Camera p_228426_6_, GameRenderer p_228426_7_, LightTexture p_228426_8_, Matrix4f p_228426_9_, CallbackInfo ci) {
|
||||||
GlStateManager._depthMask(false);
|
GlStateManager._depthMask(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,37 +15,37 @@ import com.jozufozu.flywheel.core.crumbling.CrumblingRenderer;
|
||||||
import com.jozufozu.flywheel.event.BeginFrameEvent;
|
import com.jozufozu.flywheel.event.BeginFrameEvent;
|
||||||
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
|
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
|
||||||
import com.jozufozu.flywheel.event.RenderLayerEvent;
|
import com.jozufozu.flywheel.event.RenderLayerEvent;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
import net.minecraft.client.Camera;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.RenderTypeBuffers;
|
import net.minecraft.client.renderer.RenderBuffers;
|
||||||
import net.minecraft.client.renderer.WorldRenderer;
|
import net.minecraft.client.renderer.LevelRenderer;
|
||||||
import net.minecraft.client.renderer.culling.ClippingHelper;
|
import net.minecraft.client.renderer.culling.Frustum;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
import com.mojang.math.Matrix4f;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@Mixin(WorldRenderer.class)
|
@Mixin(LevelRenderer.class)
|
||||||
public class RenderHooksMixin {
|
public class RenderHooksMixin {
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
private ClientWorld level;
|
private ClientLevel level;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
@Final
|
@Final
|
||||||
private RenderTypeBuffers renderBuffers;
|
private RenderBuffers renderBuffers;
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "setupRender")
|
@Inject(at = @At("HEAD"), method = "setupRender")
|
||||||
private void setupRender(ActiveRenderInfo info, ClippingHelper clippingHelper, boolean p_228437_3_, int frameCount, boolean isSpectator, CallbackInfo ci) {
|
private void setupRender(Camera info, Frustum clippingHelper, boolean p_228437_3_, int frameCount, boolean isSpectator, CallbackInfo ci) {
|
||||||
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, info, clippingHelper));
|
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, info, clippingHelper));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,9 +55,9 @@ 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, MatrixStack stack, double camX, double camY, double camZ, CallbackInfo ci) {
|
private void renderLayer(RenderType type, PoseStack stack, double camX, double camY, double camZ, CallbackInfo ci) {
|
||||||
|
|
||||||
RenderTypeBuffers renderBuffers = this.renderBuffers;
|
RenderBuffers renderBuffers = this.renderBuffers;
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.post(new RenderLayerEvent(level, type, stack, renderBuffers, camX, camY, camZ));
|
MinecraftForge.EVENT_BUS.post(new RenderLayerEvent(level, type, stack, renderBuffers, camX, camY, camZ));
|
||||||
|
|
||||||
|
@ -77,7 +77,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/WorldRenderer;checkPoseStack(Lcom/mojang/blaze3d/matrix/MatrixStack;)V", ordinal = 2 // after the game renders the breaking overlay normally
|
||||||
), method = "renderLevel")
|
), method = "renderLevel")
|
||||||
private void renderBlockBreaking(MatrixStack stack, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, ActiveRenderInfo 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()
|
||||||
.available()) return;
|
.available()) return;
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class RenderHooksMixin {
|
||||||
viewProjection.multiplyBackward(Backend.getInstance()
|
viewProjection.multiplyBackward(Backend.getInstance()
|
||||||
.getProjectionMatrix());
|
.getProjectionMatrix());
|
||||||
|
|
||||||
Vector3d cameraPos = info.getPosition();
|
Vec3 cameraPos = info.getPosition();
|
||||||
CrumblingRenderer.renderBreaking(level, viewProjection, cameraPos.x, cameraPos.y, cameraPos.z);
|
CrumblingRenderer.renderBreaking(level, viewProjection, cameraPos.x, cameraPos.y, cameraPos.z);
|
||||||
|
|
||||||
if (!OptifineHandler.usingShaders()) GL20.glUseProgram(0);
|
if (!OptifineHandler.usingShaders()) GL20.glUseProgram(0);
|
||||||
|
|
|
@ -11,8 +11,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import com.jozufozu.flywheel.backend.OptifineHandler;
|
import com.jozufozu.flywheel.backend.OptifineHandler;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.gui.screen.VideoSettingsScreen;
|
import net.minecraft.client.gui.screens.VideoSettingsScreen;
|
||||||
|
|
||||||
@Mixin(Minecraft.class)
|
@Mixin(Minecraft.class)
|
||||||
public class ShaderCloseMixin {
|
public class ShaderCloseMixin {
|
||||||
|
|
|
@ -7,10 +7,10 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
import com.mojang.math.Matrix4f;
|
||||||
|
|
||||||
@Mixin(GameRenderer.class)
|
@Mixin(GameRenderer.class)
|
||||||
public abstract class StoreProjectionMatrixMixin {
|
public abstract class StoreProjectionMatrixMixin {
|
||||||
|
@ -23,7 +23,7 @@ public abstract class StoreProjectionMatrixMixin {
|
||||||
* 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(Lnet/minecraft/util/math/vector/Matrix4f;)V"))
|
||||||
private void projectionMatrixReady(float p_228378_1_, long p_228378_2_, MatrixStack 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,20 +10,20 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
|
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
|
||||||
|
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
@Mixin(TileEntity.class)
|
@Mixin(BlockEntity.class)
|
||||||
public class TileRemoveMixin {
|
public class TileRemoveMixin {
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
@Nullable
|
@Nullable
|
||||||
protected World level;
|
protected Level level;
|
||||||
|
|
||||||
@Inject(at = @At("TAIL"), method = "setRemoved")
|
@Inject(at = @At("TAIL"), method = "setRemoved")
|
||||||
private void onRemove(CallbackInfo ci) {
|
private void onRemove(CallbackInfo ci) {
|
||||||
if (level instanceof ClientWorld) InstancedRenderDispatcher.getTiles(this.level)
|
if (level instanceof ClientLevel) InstancedRenderDispatcher.getTiles(this.level)
|
||||||
.remove((TileEntity) (Object) this);
|
.remove((BlockEntity) (Object) this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,16 +13,16 @@ 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;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@Mixin(value = World.class, priority = 1100) // this and create.mixins.json have high priority to load after Performant
|
@Mixin(value = Level.class, priority = 1100) // this and create.mixins.json have high priority to load after Performant
|
||||||
public class TileWorldHookMixin {
|
public class TileWorldHookMixin {
|
||||||
|
|
||||||
final World self = (World) (Object) this;
|
final Level self = (Level) (Object) this;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
@Final
|
@Final
|
||||||
|
@ -30,10 +30,10 @@ public class TileWorldHookMixin {
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
@Final
|
@Final
|
||||||
protected Set<TileEntity> blockEntitiesToUnload;
|
protected Set<BlockEntity> blockEntitiesToUnload;
|
||||||
|
|
||||||
@Inject(at = @At("TAIL"), method = "addBlockEntity")
|
@Inject(at = @At("TAIL"), method = "addBlockEntity")
|
||||||
private void onAddTile(TileEntity te, CallbackInfoReturnable<Boolean> cir) {
|
private void onAddTile(BlockEntity te, CallbackInfoReturnable<Boolean> cir) {
|
||||||
if (isClientSide) {
|
if (isClientSide) {
|
||||||
InstancedRenderDispatcher.getTiles(self)
|
InstancedRenderDispatcher.getTiles(self)
|
||||||
.queueAdd(te);
|
.queueAdd(te);
|
||||||
|
@ -46,8 +46,8 @@ public class TileWorldHookMixin {
|
||||||
@Inject(at = @At(value = "INVOKE", target = "Ljava/util/Set;clear()V", ordinal = 0), method = "tickBlockEntities")
|
@Inject(at = @At(value = "INVOKE", target = "Ljava/util/Set;clear()V", ordinal = 0), method = "tickBlockEntities")
|
||||||
private void onChunkUnload(CallbackInfo ci) {
|
private void onChunkUnload(CallbackInfo ci) {
|
||||||
if (isClientSide) {
|
if (isClientSide) {
|
||||||
InstanceManager<TileEntity> kineticRenderer = InstancedRenderDispatcher.getTiles(self);
|
InstanceManager<BlockEntity> kineticRenderer = InstancedRenderDispatcher.getTiles(self);
|
||||||
for (TileEntity tile : blockEntitiesToUnload) {
|
for (BlockEntity tile : blockEntitiesToUnload) {
|
||||||
kineticRenderer.remove(tile);
|
kineticRenderer.remove(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue