mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-02-13 05:35: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'
|
||||
archivesBaseName = 'flywheel'
|
||||
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(16)
|
||||
|
||||
minecraft {
|
||||
mappings channel: 'official', version: "${minecraft_version}"
|
||||
|
@ -143,6 +143,7 @@ artifacts {
|
|||
archives jar, sourcesJar, javadocJar
|
||||
}
|
||||
|
||||
/*
|
||||
publishing {
|
||||
tasks.publish.dependsOn 'build'
|
||||
publications {
|
||||
|
@ -174,3 +175,4 @@ curseforge {
|
|||
mainArtifact jar
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -2,9 +2,9 @@ org.gradle.jvmargs=-Xmx3G
|
|||
org.gradle.daemon=false
|
||||
# mod version info
|
||||
mod_version=0.2.3
|
||||
mc_update_version=1.16
|
||||
minecraft_version=1.16.5
|
||||
forge_version=36.1.66
|
||||
mc_update_version=1.17
|
||||
minecraft_version=1.17.1
|
||||
forge_version=37.0.59
|
||||
|
||||
# curseforge info
|
||||
projectId=486392
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.jozufozu.flywheel.config.FlwCommands;
|
|||
import com.jozufozu.flywheel.config.FlwConfig;
|
||||
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.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
|
|
@ -20,10 +20,10 @@ import com.jozufozu.flywheel.config.FlwConfig;
|
|||
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public class Backend {
|
||||
public static final Logger log = LogManager.getLogger(Backend.class);
|
||||
|
@ -144,7 +144,7 @@ public class Backend {
|
|||
.chunkCaching();
|
||||
}
|
||||
|
||||
public boolean canUseInstancing(@Nullable World world) {
|
||||
public boolean canUseInstancing(@Nullable Level 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.
|
||||
*/
|
||||
public static boolean isFlywheelWorld(@Nullable IWorld world) {
|
||||
public static boolean isFlywheelWorld(@Nullable LevelAccessor world) {
|
||||
if (world == null) return false;
|
||||
|
||||
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 net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public interface IShaderContext<P extends GlProgram> {
|
||||
|
||||
|
|
|
@ -20,11 +20,11 @@ import com.mojang.serialization.DataResult;
|
|||
import com.mojang.serialization.JsonOps;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.resources.IReloadableResourceManager;
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.resource.IResourceType;
|
||||
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
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
if (minecraft != null) {
|
||||
IResourceManager manager = minecraft.getResourceManager();
|
||||
if (manager instanceof IReloadableResourceManager) {
|
||||
((IReloadableResourceManager) manager).registerReloadListener(this);
|
||||
ResourceManager manager = minecraft.getResourceManager();
|
||||
if (manager instanceof ReloadableResourceManager) {
|
||||
((ReloadableResourceManager) manager).registerReloadListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class Loader implements ISelectiveResourceReloadListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager manager, Predicate<IResourceType> predicate) {
|
||||
public void onResourceManagerReload(ResourceManager manager, Predicate<IResourceType> predicate) {
|
||||
if (predicate.test(VanillaResourceType.SHADERS)) {
|
||||
backend.refresh();
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class Loader implements ISelectiveResourceReloadListener {
|
|||
|
||||
Backend.log.info("Loaded all shader programs.");
|
||||
|
||||
ClientWorld world = Minecraft.getInstance().level;
|
||||
ClientLevel world = Minecraft.getInstance().level;
|
||||
if (Backend.isFlywheelWorld(world)) {
|
||||
// TODO: looks like it might be good to have another event here
|
||||
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"));
|
||||
|
||||
for (ResourceLocation location : programSpecs) {
|
||||
try {
|
||||
IResource file = manager.getResource(location);
|
||||
Resource file = manager.getResource(location);
|
||||
|
||||
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.gamestate.IGameStateProvider;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class SpecMetaRegistry {
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ import com.jozufozu.flywheel.backend.Backend;
|
|||
import com.jozufozu.flywheel.backend.gl.GlObject;
|
||||
import com.jozufozu.flywheel.util.RenderUtil;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import com.mojang.math.Matrix4f;
|
||||
|
||||
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.versioned.GlCompat;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
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.ListenerStatus;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
|
||||
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.world = world;
|
||||
}
|
||||
|
@ -73,16 +73,16 @@ public abstract class AbstractInstance implements IInstance, ILightUpdateListene
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onLightUpdate(LightProvider world, LightType type, ImmutableBox changed) {
|
||||
public void onLightUpdate(LightProvider world, LightLayer type, ImmutableBox changed) {
|
||||
updateLight();
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.jozufozu.flywheel.backend.instancing;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public interface IInstance {
|
||||
BlockPos getWorldPosition();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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.
|
||||
|
@ -14,5 +14,5 @@ public interface IInstanceRendered {
|
|||
return false;
|
||||
}
|
||||
|
||||
World getWorld();
|
||||
Level getWorld();
|
||||
}
|
||||
|
|
|
@ -14,10 +14,10 @@ import com.jozufozu.flywheel.backend.material.MaterialManagerImpl;
|
|||
import com.jozufozu.flywheel.light.LightUpdater;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.Mth;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
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++;
|
||||
processQueuedAdditions();
|
||||
|
||||
|
@ -266,7 +266,7 @@ public abstract class InstanceManager<T> implements MaterialManagerImpl.OriginSh
|
|||
|
||||
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) {
|
||||
|
|
|
@ -10,9 +10,9 @@ import com.jozufozu.flywheel.event.BeginFrameEvent;
|
|||
import com.jozufozu.flywheel.event.RenderLayerEvent;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
/**
|
||||
* A manager class for a single world where instancing is supported.
|
||||
|
@ -23,7 +23,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
public class InstanceWorld {
|
||||
protected final MaterialManagerImpl<WorldProgram> materialManager;
|
||||
protected final InstanceManager<Entity> entityInstanceManager;
|
||||
protected final InstanceManager<TileEntity> tileEntityInstanceManager;
|
||||
protected final InstanceManager<BlockEntity> tileEntityInstanceManager;
|
||||
|
||||
public InstanceWorld() {
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class InstanceWorld {
|
|||
return entityInstanceManager;
|
||||
}
|
||||
|
||||
public InstanceManager<TileEntity> getTileEntityInstanceManager() {
|
||||
public InstanceManager<BlockEntity> getTileEntityInstanceManager() {
|
||||
return tileEntityInstanceManager;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class InstanceWorld {
|
|||
/**
|
||||
* 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.entitiesForRendering()
|
||||
.forEach(entityInstanceManager::add);
|
||||
|
|
|
@ -10,10 +10,10 @@ import com.jozufozu.flywheel.util.AnimationTickHolder;
|
|||
import com.jozufozu.flywheel.util.WorldAttached;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
|
@ -30,7 +30,7 @@ public class InstancedRenderDispatcher {
|
|||
* Call this when you want to manually run {@link AbstractInstance#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);
|
||||
}
|
||||
|
||||
|
@ -43,13 +43,13 @@ public class InstancedRenderDispatcher {
|
|||
}
|
||||
|
||||
@Nonnull
|
||||
public static InstanceManager<TileEntity> getTiles(IWorld world) {
|
||||
public static InstanceManager<BlockEntity> getTiles(LevelAccessor world) {
|
||||
return instanceWorlds.get(world)
|
||||
.getTileEntityInstanceManager();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static InstanceManager<Entity> getEntities(IWorld world) {
|
||||
public static InstanceManager<Entity> getEntities(LevelAccessor world) {
|
||||
return instanceWorlds.get(world)
|
||||
.getEntityInstanceManager();
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class InstancedRenderDispatcher {
|
|||
return;
|
||||
}
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
ClientWorld world = mc.level;
|
||||
ClientLevel world = mc.level;
|
||||
AnimationTickHolder.tick();
|
||||
|
||||
instanceWorlds.get(world).tick();
|
||||
|
@ -79,7 +79,7 @@ public class InstancedRenderDispatcher {
|
|||
public static void renderLayer(RenderLayerEvent event) {
|
||||
if (event.layer == null) return;
|
||||
|
||||
ClientWorld world = event.getWorld();
|
||||
ClientLevel world = event.getWorld();
|
||||
if (!Backend.getInstance()
|
||||
.canUseInstancing(world)) return;
|
||||
|
||||
|
@ -88,14 +88,14 @@ public class InstancedRenderDispatcher {
|
|||
|
||||
@SubscribeEvent
|
||||
public static void onReloadRenderers(ReloadRenderersEvent event) {
|
||||
ClientWorld world = event.getWorld();
|
||||
ClientLevel world = event.getWorld();
|
||||
if (Backend.getInstance()
|
||||
.canUseInstancing() && world != null) {
|
||||
loadAllInWorld(world);
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadAllInWorld(ClientWorld world) {
|
||||
public static void loadAllInWorld(ClientLevel world) {
|
||||
instanceWorlds.replace(world, InstanceWorld::delete)
|
||||
.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.Object2BooleanMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
||||
public class InstancedRenderRegistry {
|
||||
private static final InstancedRenderRegistry INSTANCE = new InstancedRenderRegistry();
|
||||
|
@ -26,14 +26,14 @@ public class InstancedRenderRegistry {
|
|||
}
|
||||
|
||||
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();
|
||||
|
||||
protected InstancedRenderRegistry() {
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class InstancedRenderRegistry {
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class InstancedRenderRegistry {
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class InstancedRenderRegistry {
|
|||
* @deprecated will be removed in 0.3.0, use {@link #tile}
|
||||
*/
|
||||
@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)
|
||||
.factory(rendererFactory);
|
||||
}
|
||||
|
@ -77,8 +77,8 @@ public class InstancedRenderRegistry {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public <T extends TileEntity> TileEntityInstance<? super T> create(MaterialManager manager, T tile) {
|
||||
TileEntityType<?> type = tile.getType();
|
||||
public <T extends BlockEntity> TileEntityInstance<? super T> create(MaterialManager manager, T tile) {
|
||||
BlockEntityType<?> type = tile.getType();
|
||||
ITileInstanceFactory<? super T> factory = (ITileInstanceFactory<? super T>) this.tiles.get(type);
|
||||
|
||||
if (factory == null) return null;
|
||||
|
@ -107,12 +107,12 @@ public class InstancedRenderRegistry {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,14 +10,14 @@ import com.jozufozu.flywheel.light.ILightUpdateListener;
|
|||
import com.jozufozu.flywheel.light.IMovingListener;
|
||||
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.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.core.Vec3i;
|
||||
|
||||
/**
|
||||
* The layer between a {@link TileEntity} and the Flywheel backend.
|
||||
|
@ -52,7 +52,7 @@ public abstract class EntityInstance<E extends Entity> extends AbstractInstance
|
|||
|
||||
@Override
|
||||
public boolean update(LightProvider provider) {
|
||||
AxisAlignedBB boundsNow = entity.getBoundingBox();
|
||||
AABB boundsNow = entity.getBoundingBox();
|
||||
|
||||
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.
|
||||
*/
|
||||
public Vector3f getInstancePosition() {
|
||||
Vector3d pos = entity.position();
|
||||
Vector3i origin = materialManager.getOriginCoordinate();
|
||||
Vec3 pos = entity.position();
|
||||
Vec3i origin = materialManager.getOriginCoordinate();
|
||||
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.
|
||||
*/
|
||||
public Vector3f getInstancePosition(float partialTicks) {
|
||||
Vector3d pos = entity.position();
|
||||
Vector3i origin = materialManager.getOriginCoordinate();
|
||||
Vec3 pos = entity.position();
|
||||
Vec3i origin = materialManager.getOriginCoordinate();
|
||||
return new Vector3f(
|
||||
(float) (MathHelper.lerp(partialTicks, entity.xOld, pos.x) - origin.getX()),
|
||||
(float) (MathHelper.lerp(partialTicks, entity.yOld, pos.y) - origin.getY()),
|
||||
(float) (MathHelper.lerp(partialTicks, entity.zOld, pos.z) - origin.getZ())
|
||||
(float) (Mth.lerp(partialTicks, entity.xOld, pos.x) - origin.getX()),
|
||||
(float) (Mth.lerp(partialTicks, entity.yOld, pos.y) - origin.getY()),
|
||||
(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.material.MaterialManagerImpl;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public class EntityInstanceManager extends InstanceManager<Entity> {
|
||||
|
||||
|
@ -32,14 +32,14 @@ public class EntityInstanceManager extends InstanceManager<Entity> {
|
|||
protected boolean canCreateInstance(Entity entity) {
|
||||
if (!entity.isAlive()) return false;
|
||||
|
||||
World world = entity.level;
|
||||
Level world = entity.level;
|
||||
|
||||
if (world == null) return false;
|
||||
|
||||
if (Backend.isFlywheelWorld(world)) {
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.backend.instancing.entity;
|
|||
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
@FunctionalInterface
|
||||
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 net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ITileInstanceFactory<T extends TileEntity> {
|
||||
public interface ITileInstanceFactory<T extends BlockEntity> {
|
||||
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.ImmutableBox;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public abstract class TileEntityInstance<T extends TileEntity> extends AbstractInstance {
|
||||
public abstract class TileEntityInstance<T extends BlockEntity> extends AbstractInstance {
|
||||
|
||||
protected final T tile;
|
||||
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.material.MaterialManagerImpl;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public class TileInstanceManager extends InstanceManager<TileEntity> {
|
||||
public class TileInstanceManager extends InstanceManager<BlockEntity> {
|
||||
|
||||
public TileInstanceManager(MaterialManagerImpl<?> materialManager) {
|
||||
super(materialManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canInstance(TileEntity obj) {
|
||||
protected boolean canInstance(BlockEntity obj) {
|
||||
return obj != null && InstancedRenderRegistry.getInstance().canInstance(obj.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractInstance createRaw(TileEntity obj) {
|
||||
protected AbstractInstance createRaw(BlockEntity obj) {
|
||||
return InstancedRenderRegistry.getInstance()
|
||||
.create(materialManager, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canCreateInstance(TileEntity tile) {
|
||||
protected boolean canCreateInstance(BlockEntity tile) {
|
||||
if (tile.isRemoved()) return false;
|
||||
|
||||
World world = tile.getLevel();
|
||||
Level world = tile.getLevel();
|
||||
|
||||
if (world == null) return false;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class TileInstanceManager extends InstanceManager<TileEntity> {
|
|||
if (Backend.isFlywheelWorld(world)) {
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -9,10 +9,10 @@ import com.jozufozu.flywheel.core.model.BlockModel;
|
|||
import com.jozufozu.flywheel.core.model.IModel;
|
||||
import com.jozufozu.flywheel.util.Pair;
|
||||
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.util.Direction;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.core.Direction;
|
||||
|
||||
public interface Material<D extends InstanceData> {
|
||||
/**
|
||||
|
@ -32,7 +32,7 @@ public interface Material<D extends InstanceData> {
|
|||
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()));
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
|||
import com.jozufozu.flywheel.backend.state.IRenderState;
|
||||
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.
|
||||
|
|
|
@ -4,8 +4,8 @@ import com.jozufozu.flywheel.backend.state.IRenderState;
|
|||
import com.jozufozu.flywheel.backend.state.RenderLayer;
|
||||
import com.jozufozu.flywheel.backend.state.TextureRenderState;
|
||||
|
||||
import net.minecraft.inventory.container.PlayerContainer;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
import net.minecraft.world.inventory.InventoryMenu;
|
||||
import net.minecraft.core.Vec3i;
|
||||
|
||||
public interface MaterialManager {
|
||||
|
||||
|
@ -18,7 +18,7 @@ public interface MaterialManager {
|
|||
*/
|
||||
MaterialGroup state(RenderLayer layer, IRenderState state);
|
||||
|
||||
Vector3i getOriginCoordinate();
|
||||
Vec3i getOriginCoordinate();
|
||||
|
||||
default MaterialGroup solid(IRenderState state) {
|
||||
return state(RenderLayer.SOLID, state);
|
||||
|
@ -33,14 +33,14 @@ public interface MaterialManager {
|
|||
}
|
||||
|
||||
default MaterialGroup defaultSolid() {
|
||||
return solid(TextureRenderState.get(PlayerContainer.BLOCK_ATLAS));
|
||||
return solid(TextureRenderState.get(InventoryMenu.BLOCK_ATLAS));
|
||||
}
|
||||
|
||||
default MaterialGroup defaultCutout() {
|
||||
return cutout(TextureRenderState.get(PlayerContainer.BLOCK_ATLAS));
|
||||
return cutout(TextureRenderState.get(InventoryMenu.BLOCK_ATLAS));
|
||||
}
|
||||
|
||||
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.util.WeakHashSet;
|
||||
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.Mth;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraft.core.Vec3i;
|
||||
|
||||
public class MaterialManagerImpl<P extends WorldProgram> implements MaterialManager {
|
||||
|
||||
|
@ -105,7 +105,7 @@ public class MaterialManagerImpl<P extends WorldProgram> implements MaterialMana
|
|||
}
|
||||
|
||||
@Override
|
||||
public Vector3i getOriginCoordinate() {
|
||||
public Vec3i getOriginCoordinate() {
|
||||
return originCoordinate;
|
||||
}
|
||||
|
||||
|
@ -118,10 +118,10 @@ public class MaterialManagerImpl<P extends WorldProgram> implements MaterialMana
|
|||
*
|
||||
* This prevents floating point precision issues at high coordinates.
|
||||
*/
|
||||
public void beginFrame(ActiveRenderInfo info) {
|
||||
int cX = MathHelper.floor(info.getPosition().x);
|
||||
int cY = MathHelper.floor(info.getPosition().y);
|
||||
int cZ = MathHelper.floor(info.getPosition().z);
|
||||
public void beginFrame(Camera info) {
|
||||
int cX = Mth.floor(info.getPosition().x);
|
||||
int cY = Mth.floor(info.getPosition().y);
|
||||
int cZ = Mth.floor(info.getPosition().z);
|
||||
|
||||
int dX = cX - originCoordinate.getX();
|
||||
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.core.shader.WorldProgram;
|
||||
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import com.mojang.math.Matrix4f;
|
||||
|
||||
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.struct.StructType;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
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.SourceFile;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
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.ProgramState;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
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.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.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.jozufozu.flywheel.backend.source;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
/**
|
||||
* 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.ShaderStruct;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
/**
|
||||
* 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.Map;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
/**
|
||||
* 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.StreamUtil;
|
||||
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
/**
|
||||
* The main object for loading and parsing source files.
|
||||
|
@ -25,7 +25,7 @@ public class ShaderSources implements ISourceHolder {
|
|||
|
||||
public final Index index;
|
||||
|
||||
public ShaderSources(IResourceManager manager) {
|
||||
public ShaderSources(ResourceManager manager) {
|
||||
Collection<ResourceLocation> allShaders = manager.listResources(SHADER_DIR, s -> {
|
||||
for (String ext : EXTENSIONS) {
|
||||
if (s.endsWith(ext)) return true;
|
||||
|
@ -35,7 +35,7 @@ public class ShaderSources implements ISourceHolder {
|
|||
|
||||
for (ResourceLocation location : allShaders) {
|
||||
try {
|
||||
IResource resource = manager.getResource(location);
|
||||
Resource resource = manager.getResource(location);
|
||||
|
||||
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.IntList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class SourceFile {
|
||||
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.span.Span;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class Import extends AbstractShaderElement {
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import javax.annotation.Nullable;
|
|||
|
||||
import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public interface IRenderState {
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import javax.annotation.Nullable;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class RenderState implements IRenderState {
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
|
|||
import com.jozufozu.flywheel.util.Pair;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class TextureRenderState implements IRenderState {
|
||||
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 net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
|
@ -33,11 +33,11 @@ public enum BooleanConfig {
|
|||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static void enabled(BooleanDirective state) {
|
||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||
LocalPlayer player = Minecraft.getInstance().player;
|
||||
if (player == null || state == null) return;
|
||||
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
@ -47,8 +47,8 @@ public enum BooleanConfig {
|
|||
|
||||
FlwConfig.get().client.enabled.set(enabled);
|
||||
|
||||
ITextComponent text = boolToText(FlwConfig.get().client.enabled.get()).append(new StringTextComponent(" Flywheel renderer").withStyle(TextFormatting.WHITE));
|
||||
ITextComponent error = new StringTextComponent("Flywheel renderer does not support Optifine Shaders").withStyle(TextFormatting.RED);
|
||||
Component text = boolToText(FlwConfig.get().client.enabled.get()).append(new TextComponent(" Flywheel renderer").withStyle(ChatFormatting.WHITE));
|
||||
Component error = new TextComponent("Flywheel renderer does not support Optifine Shaders").withStyle(ChatFormatting.RED);
|
||||
|
||||
player.displayClientMessage(cannotUse ? error : text, false);
|
||||
Backend.reloadWorldRenderers();
|
||||
|
@ -56,42 +56,42 @@ public enum BooleanConfig {
|
|||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static void normalOverlay(BooleanDirective state) {
|
||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||
LocalPlayer player = Minecraft.getInstance().player;
|
||||
if (player == null || state == null) return;
|
||||
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static void chunkCaching(BooleanDirective state) {
|
||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||
LocalPlayer player = Minecraft.getInstance().player;
|
||||
if (player == null || state == null) return;
|
||||
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
Backend.reloadWorldRenderers();
|
||||
}
|
||||
|
||||
private static IFormattableTextComponent boolToText(boolean b) {
|
||||
return b ? new StringTextComponent("enabled").withStyle(TextFormatting.DARK_GREEN) : new StringTextComponent("disabled").withStyle(TextFormatting.RED);
|
||||
private static MutableComponent boolToText(boolean b) {
|
||||
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.builder.ArgumentBuilder;
|
||||
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
|
||||
public class BooleanConfigCommand {
|
||||
|
@ -19,24 +19,24 @@ public class BooleanConfigCommand {
|
|||
this.value = value;
|
||||
}
|
||||
|
||||
public ArgumentBuilder<CommandSource, ?> register() {
|
||||
public ArgumentBuilder<CommandSourceStack, ?> register() {
|
||||
return Commands.literal(name)
|
||||
.executes(context -> {
|
||||
ServerPlayerEntity player = context.getSource()
|
||||
ServerPlayer player = context.getSource()
|
||||
.getPlayerOrException();
|
||||
FlwPackets.channel.send(PacketDistributor.PLAYER.with(() -> player), new SConfigureBooleanPacket(value, BooleanDirective.DISPLAY));
|
||||
return Command.SINGLE_SUCCESS;
|
||||
})
|
||||
.then(Commands.literal("on")
|
||||
.executes(context -> {
|
||||
ServerPlayerEntity player = context.getSource()
|
||||
ServerPlayer player = context.getSource()
|
||||
.getPlayerOrException();
|
||||
FlwPackets.channel.send(PacketDistributor.PLAYER.with(() -> player), new SConfigureBooleanPacket(value, BooleanDirective.TRUE));
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}))
|
||||
.then(Commands.literal("off")
|
||||
.executes(context -> {
|
||||
ServerPlayerEntity player = context.getSource()
|
||||
ServerPlayer player = context.getSource()
|
||||
.getPlayerOrException();
|
||||
FlwPackets.channel.send(PacketDistributor.PLAYER.with(() -> player), new SConfigureBooleanPacket(value, BooleanDirective.FALSE));
|
||||
return Command.SINGLE_SUCCESS;
|
||||
|
|
|
@ -2,15 +2,15 @@ package com.jozufozu.flywheel.config;
|
|||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
||||
|
||||
public class FlwCommands {
|
||||
@SubscribeEvent
|
||||
public static void onServerStarting(FMLServerStartingEvent event) {
|
||||
CommandDispatcher<CommandSource> dispatcher = event.getServer()
|
||||
CommandDispatcher<CommandSourceStack> dispatcher = event.getServer()
|
||||
.getCommands()
|
||||
.getDispatcher();
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.config;
|
|||
|
||||
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.NetworkRegistry;
|
||||
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.config;
|
|||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
|
||||
/**
|
||||
|
@ -18,12 +18,12 @@ public class SConfigureBooleanPacket {
|
|||
this.directive = directive;
|
||||
}
|
||||
|
||||
public SConfigureBooleanPacket(PacketBuffer buffer) {
|
||||
public SConfigureBooleanPacket(FriendlyByteBuf buffer) {
|
||||
target = BooleanConfig.values()[buffer.readByte()];
|
||||
directive = BooleanDirective.values()[buffer.readByte()];
|
||||
}
|
||||
|
||||
public void encode(PacketBuffer buffer) {
|
||||
public void encode(FriendlyByteBuf buffer) {
|
||||
buffer.writeByte(target.ordinal());
|
||||
buffer.writeByte(directive.ordinal());
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.jozufozu.flywheel.core;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.container.PlayerContainer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.inventory.InventoryMenu;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ public class AtlasStitcher {
|
|||
public void onTextureStitch(TextureStitchEvent.Pre event) {
|
||||
if (!event.getMap()
|
||||
.location()
|
||||
.equals(PlayerContainer.BLOCK_ATLAS)) return;
|
||||
.equals(InventoryMenu.BLOCK_ATLAS)) return;
|
||||
|
||||
sprites.forEach(StitchedSprite::reset);
|
||||
sprites.stream()
|
||||
|
|
|
@ -16,7 +16,7 @@ import com.jozufozu.flywheel.core.shader.gamestate.NormalDebugStateProvider;
|
|||
import com.jozufozu.flywheel.event.GatherContextEvent;
|
||||
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.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.event.GatherContextEvent;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
|
@ -27,7 +27,7 @@ public class PartialModel {
|
|||
private static final List<PartialModel> all = new ArrayList<>();
|
||||
|
||||
protected final ResourceLocation modelLocation;
|
||||
protected IBakedModel bakedModel;
|
||||
protected BakedModel bakedModel;
|
||||
|
||||
public PartialModel(ResourceLocation modelLocation) {
|
||||
|
||||
|
@ -45,12 +45,12 @@ public class PartialModel {
|
|||
}
|
||||
|
||||
public static void onModelBake(ModelBakeEvent event) {
|
||||
Map<ResourceLocation, IBakedModel> modelRegistry = event.getModelRegistry();
|
||||
Map<ResourceLocation, BakedModel> modelRegistry = event.getModelRegistry();
|
||||
for (PartialModel partial : all)
|
||||
partial.bakedModel = modelRegistry.get(partial.modelLocation);
|
||||
}
|
||||
|
||||
public IBakedModel get() {
|
||||
public BakedModel get() {
|
||||
return bakedModel;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.jozufozu.flywheel.core;
|
|||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class Programs {
|
||||
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.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.inventory.container.PlayerContainer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.inventory.InventoryMenu;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class StitchedSprite {
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class StitchedSprite {
|
|||
public TextureAtlasSprite getSprite() {
|
||||
if (sprite == null) {
|
||||
sprite = Minecraft.getInstance()
|
||||
.getTextureAtlas(PlayerContainer.BLOCK_ATLAS)
|
||||
.getTextureAtlas(InventoryMenu.BLOCK_ATLAS)
|
||||
.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.spec.ProgramSpec;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class WorldContext<P extends WorldProgram> implements IShaderContext<P> {
|
||||
public final Backend backend;
|
||||
|
|
|
@ -6,20 +6,20 @@ import java.util.Map;
|
|||
import com.jozufozu.flywheel.mixin.atlas.SheetDataAccessor;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.Texture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class AtlasInfo {
|
||||
|
||||
private static final Map<ResourceLocation, SheetData> sheetData = new HashMap<>();
|
||||
|
||||
public static AtlasTexture getAtlas(ResourceLocation name) {
|
||||
Texture texture = Minecraft.getInstance().textureManager.getTexture(name);
|
||||
public static TextureAtlas getAtlas(ResourceLocation name) {
|
||||
AbstractTexture texture = Minecraft.getInstance().textureManager.getTexture(name);
|
||||
|
||||
if (texture instanceof AtlasTexture)
|
||||
return (AtlasTexture) texture;
|
||||
if (texture instanceof TextureAtlas)
|
||||
return (TextureAtlas) texture;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class AtlasInfo {
|
|||
return getAtlasData(texture.atlas());
|
||||
}
|
||||
|
||||
public static SheetData getAtlasData(AtlasTexture atlas) {
|
||||
public static SheetData getAtlasData(TextureAtlas atlas) {
|
||||
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.SheetData;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
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.material.MaterialManagerImpl;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
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.extension.IProgramExtension;
|
||||
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.inventory.container.PlayerContainer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.inventory.InventoryMenu;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class CrumblingProgram extends WorldProgram {
|
||||
protected final int uTextureScale;
|
||||
|
@ -35,7 +35,7 @@ public class CrumblingProgram extends WorldProgram {
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
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.longs.Long2ObjectMap;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.DestroyBlockProgress;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.server.level.BlockDestructionProgress;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.texture.Texture;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
@ -53,28 +53,28 @@ public class CrumblingRenderer {
|
|||
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()
|
||||
.canUseInstancing(world)) return;
|
||||
|
||||
Int2ObjectMap<List<TileEntity>> activeStages = getActiveStageTiles(world);
|
||||
Int2ObjectMap<List<BlockEntity>> activeStages = getActiveStageTiles(world);
|
||||
|
||||
if (activeStages.isEmpty()) return;
|
||||
|
||||
State state = STATE.get();
|
||||
RenderType layer = ModelBakery.DESTROY_TYPES.get(0);
|
||||
|
||||
InstanceManager<TileEntity> renderer = state.instanceManager;
|
||||
InstanceManager<BlockEntity> renderer = state.instanceManager;
|
||||
|
||||
TextureManager textureManager = Minecraft.getInstance().textureManager;
|
||||
ActiveRenderInfo info = Minecraft.getInstance().gameRenderer.getMainCamera();
|
||||
Camera info = Minecraft.getInstance().gameRenderer.getMainCamera();
|
||||
|
||||
MaterialManagerImpl<CrumblingProgram> materials = state.materialManager;
|
||||
layer.setupRenderState();
|
||||
|
||||
for (Int2ObjectMap.Entry<List<TileEntity>> stage : activeStages.int2ObjectEntrySet()) {
|
||||
for (Int2ObjectMap.Entry<List<BlockEntity>> stage : activeStages.int2ObjectEntrySet()) {
|
||||
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
|
||||
if (breaking != null) {
|
||||
|
@ -94,30 +94,30 @@ public class CrumblingRenderer {
|
|||
layer.clearRenderState();
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
* Associate each breaking stage with a list of all tile entities at that stage.
|
||||
*/
|
||||
private static Int2ObjectMap<List<TileEntity>> getActiveStageTiles(ClientWorld world) {
|
||||
Long2ObjectMap<SortedSet<DestroyBlockProgress>> breakingProgressions = Minecraft.getInstance().levelRenderer.destructionProgress;
|
||||
private static Int2ObjectMap<List<BlockEntity>> getActiveStageTiles(ClientLevel world) {
|
||||
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());
|
||||
|
||||
SortedSet<DestroyBlockProgress> progresses = entry.getValue();
|
||||
SortedSet<BlockDestructionProgress> progresses = entry.getValue();
|
||||
if (progresses != null && !progresses.isEmpty()) {
|
||||
int blockDamage = progresses.last()
|
||||
.getProgress();
|
||||
|
||||
TileEntity tileEntity = world.getBlockEntity(breakingPos);
|
||||
BlockEntity tileEntity = world.getBlockEntity(breakingPos);
|
||||
|
||||
if (tileEntity != null) {
|
||||
List<TileEntity> tileEntities = breakingEntities.computeIfAbsent(blockDamage, $ -> new ArrayList<>());
|
||||
List<BlockEntity> tileEntities = breakingEntities.computeIfAbsent(blockDamage, $ -> new ArrayList<>());
|
||||
tileEntities.add(tileEntity);
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ public class CrumblingRenderer {
|
|||
|
||||
@SubscribeEvent
|
||||
public static void onReloadRenderers(ReloadRenderersEvent event) {
|
||||
ClientWorld world = event.getWorld();
|
||||
ClientLevel world = event.getWorld();
|
||||
if (Backend.getInstance()
|
||||
.canUseInstancing() && world != null) {
|
||||
reset();
|
||||
|
@ -141,7 +141,7 @@ public class CrumblingRenderer {
|
|||
|
||||
private static class State {
|
||||
private final MaterialManagerImpl<CrumblingProgram> materialManager;
|
||||
private final InstanceManager<TileEntity> instanceManager;
|
||||
private final InstanceManager<BlockEntity> instanceManager;
|
||||
|
||||
private State() {
|
||||
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.core.materials.BasicData;
|
||||
import com.jozufozu.flywheel.util.RenderUtil;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
public class ModelData extends BasicData {
|
||||
private static final float[] empty = new float[25];
|
||||
|
||||
public float[] matrices = empty;
|
||||
|
||||
public ModelData setTransform(MatrixStack stack) {
|
||||
public ModelData setTransform(PoseStack stack) {
|
||||
matrices = RenderUtil.writeMatrixStack(stack);
|
||||
markDirty();
|
||||
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.util.vec.Vec3;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import com.mojang.math.Quaternion;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
public class OrientedData extends BasicData {
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class OrientedData extends BasicData {
|
|||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -17,13 +17,13 @@ import com.jozufozu.flywheel.core.Formats;
|
|||
import com.jozufozu.flywheel.util.VirtualEmptyModelData;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.color.ItemColors;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import net.minecraft.core.Direction;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.core.Vec3i;
|
||||
|
||||
public class BakedModelModel implements IModel {
|
||||
// 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;
|
||||
|
||||
public BakedModelModel(IBakedModel model) {
|
||||
public BakedModelModel(BakedModel model) {
|
||||
this.model = model;
|
||||
|
||||
Random random = new Random();
|
||||
|
@ -80,13 +80,13 @@ public class BakedModelModel implements IModel {
|
|||
// byte blue = (byte)(i & 255);
|
||||
|
||||
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());
|
||||
int intSize = DefaultVertexFormats.BLOCK.getIntegerSize();
|
||||
int intSize = DefaultVertexFormat.BLOCK.getIntegerSize();
|
||||
int vertexCount = aint.length / intSize;
|
||||
|
||||
try (MemoryStack memorystack = MemoryStack.stackPush()) {
|
||||
ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormats.BLOCK.getVertexSize());
|
||||
ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormat.BLOCK.getVertexSize());
|
||||
IntBuffer intbuffer = bytebuffer.asIntBuffer();
|
||||
|
||||
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.util.BufferBuilderReader;
|
||||
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.renderer.BlockModelRenderer;
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.ModelBlockRenderer;
|
||||
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
/**
|
||||
* A model of a single block.
|
||||
*/
|
||||
public class BlockModel implements IModel {
|
||||
private static final MatrixStack IDENTITY = new MatrixStack();
|
||||
private static final PoseStack IDENTITY = new PoseStack();
|
||||
|
||||
private final BufferBuilderReader reader;
|
||||
|
||||
|
@ -36,11 +36,11 @@ public class BlockModel implements IModel {
|
|||
.getBlockModel(state), state);
|
||||
}
|
||||
|
||||
public BlockModel(IBakedModel model, BlockState referenceState) {
|
||||
public BlockModel(BakedModel model, BlockState referenceState) {
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
BlockRendererDispatcher dispatcher = mc.getBlockRenderer();
|
||||
BlockModelRenderer blockRenderer = dispatcher.getModelRenderer();
|
||||
BlockRenderDispatcher dispatcher = mc.getBlockRenderer();
|
||||
ModelBlockRenderer blockRenderer = dispatcher.getModelRenderer();
|
||||
BufferBuilder builder = new BufferBuilder(512);
|
||||
|
||||
// BakedQuadWrapper quadReader = new BakedQuadWrapper();
|
||||
|
@ -81,7 +81,7 @@ public class BlockModel implements IModel {
|
|||
// .flatMap(dir -> model.getQuads(referenceState, dir, mc.world.rand, modelData).stream())
|
||||
// .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);
|
||||
builder.end();
|
||||
return builder;
|
||||
|
|
|
@ -5,43 +5,43 @@ import static org.lwjgl.opengl.GL11.GL_QUADS;
|
|||
import java.util.Collection;
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BlockModelRenderer;
|
||||
import net.minecraft.client.renderer.BlockModelShapes;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.block.ModelBlockRenderer;
|
||||
import net.minecraft.client.renderer.block.BlockModelShaper;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
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.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraft.world.gen.feature.template.Template;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
import net.minecraftforge.common.util.Lazy;
|
||||
|
||||
public class ModelUtil {
|
||||
private static final Lazy<BlockModelRenderer> MODEL_RENDERER = Lazy.of(() -> new BlockModelRenderer(Minecraft.getInstance().getBlockColors()));
|
||||
private static final Lazy<BlockModelShapes> BLOCK_MODELS = Lazy.of(() -> Minecraft.getInstance().getModelManager().getBlockModelShaper());
|
||||
private static final Lazy<ModelBlockRenderer> MODEL_RENDERER = Lazy.of(() -> new ModelBlockRenderer(Minecraft.getInstance().getBlockColors()));
|
||||
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) {
|
||||
MatrixStack ms = new MatrixStack();
|
||||
public static BufferBuilder getBufferBuilderFromTemplate(BlockAndTintGetter renderWorld, RenderType layer, Collection<StructureTemplate.StructureBlockInfo> blocks) {
|
||||
PoseStack ms = new PoseStack();
|
||||
Random random = new Random();
|
||||
BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize());
|
||||
builder.begin(GL_QUADS, DefaultVertexFormats.BLOCK);
|
||||
BufferBuilder builder = new BufferBuilder(DefaultVertexFormat.BLOCK.getIntegerSize());
|
||||
builder.begin(GL_QUADS, DefaultVertexFormat.BLOCK);
|
||||
|
||||
ForgeHooksClient.setRenderLayer(layer);
|
||||
BlockModelRenderer.enableCaching();
|
||||
for (Template.BlockInfo info : blocks) {
|
||||
ModelBlockRenderer.enableCaching();
|
||||
for (StructureTemplate.StructureBlockInfo info : blocks) {
|
||||
BlockState state = info.state;
|
||||
|
||||
if (state.getRenderShape() != BlockRenderType.MODEL)
|
||||
if (state.getRenderShape() != RenderShape.MODEL)
|
||||
continue;
|
||||
if (!RenderTypeLookup.canRenderInLayer(state, layer))
|
||||
if (!ItemBlockRenderTypes.canRenderInLayer(state, layer))
|
||||
continue;
|
||||
|
||||
BlockPos pos = info.pos;
|
||||
|
@ -52,7 +52,7 @@ public class ModelUtil {
|
|||
random, 42, OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE);
|
||||
ms.popPose();
|
||||
}
|
||||
BlockModelRenderer.clearCache();
|
||||
ModelBlockRenderer.clearCache();
|
||||
ForgeHooksClient.setRenderLayer(null);
|
||||
|
||||
builder.end();
|
||||
|
|
|
@ -10,10 +10,10 @@ import java.util.Set;
|
|||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.vector.Matrix3f;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.core.Direction;
|
||||
import com.mojang.math.Matrix3f;
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
public class PartBuilder {
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.jozufozu.flywheel.core.model;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.core.Direction;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
public class Readable {
|
||||
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.RenderType;
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraft.world.gen.feature.template.Template;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||
|
||||
public class WorldModel implements IModel {
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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.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
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.jozufozu.flywheel.Flywheel;
|
|||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
import com.jozufozu.flywheel.core.shader.extension.IExtensionInstance;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
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.UnitExtensionInstance;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public enum WorldFog implements IProgramExtension {
|
||||
NONE("none", UnitExtensionInstance::new),
|
||||
|
|
|
@ -9,10 +9,10 @@ import java.util.List;
|
|||
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
||||
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.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import com.mojang.math.Matrix4f;
|
||||
|
||||
public class WorldProgram extends ExtensibleGlProgram {
|
||||
protected final int uTime = getUniformLocation("uTime");
|
||||
|
@ -45,7 +45,7 @@ public class WorldProgram extends ExtensibleGlProgram {
|
|||
public void uploadWindowSize() {
|
||||
if (uWindowSize < 0) return;
|
||||
|
||||
MainWindow window = Minecraft.getInstance().getWindow();
|
||||
Window window = Minecraft.getInstance().getWindow();
|
||||
|
||||
int height = window.getScreenHeight();
|
||||
int width = window.getScreenWidth();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.jozufozu.flywheel.core.shader.extension;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public interface IExtensionInstance {
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.SpecMetaRegistry;
|
|||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
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
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.jozufozu.flywheel.core.shader.extension;
|
|||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
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.core.shader.GlFog;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class FogStateProvider implements IGameStateProvider {
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.jozufozu.flywheel.core.shader.gamestate;
|
|||
import com.jozufozu.flywheel.backend.SpecMetaRegistry;
|
||||
import com.mojang.serialization.Codec;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public interface IGameStateProvider {
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.jozufozu.flywheel.Flywheel;
|
|||
import com.jozufozu.flywheel.config.FlwConfig;
|
||||
import com.jozufozu.flywheel.core.shader.spec.IBooleanStateProvider;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
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.mojang.serialization.Codec;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
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 net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public interface IGameStateCondition {
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.jozufozu.flywheel.backend.source.SourceFile;
|
|||
import com.mojang.serialization.Codec;
|
||||
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.
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.jozufozu.flywheel.core.shader.gamestate.IGameStateProvider;
|
|||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class SpecificValueCondition implements IGameStateCondition {
|
||||
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
package com.jozufozu.flywheel.event;
|
||||
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.culling.ClippingHelper;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class BeginFrameEvent extends Event {
|
||||
private final ClientWorld world;
|
||||
private final ActiveRenderInfo info;
|
||||
private final ClippingHelper clippingHelper;
|
||||
private final ClientLevel world;
|
||||
private final Camera info;
|
||||
private final Frustum clippingHelper;
|
||||
|
||||
public BeginFrameEvent(ClientWorld world, ActiveRenderInfo info, ClippingHelper clippingHelper) {
|
||||
public BeginFrameEvent(ClientLevel world, Camera info, Frustum clippingHelper) {
|
||||
this.world = world;
|
||||
this.info = info;
|
||||
this.clippingHelper = clippingHelper;
|
||||
}
|
||||
|
||||
public ClientWorld getWorld() {
|
||||
public ClientLevel getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public ActiveRenderInfo getInfo() {
|
||||
public Camera getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public ClippingHelper getClippingHelper() {
|
||||
public Frustum getClippingHelper() {
|
||||
return clippingHelper;
|
||||
}
|
||||
|
||||
public Vector3d getCameraPos() {
|
||||
public Vec3 getCameraPos() {
|
||||
return info.getPosition();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
|
|||
import com.jozufozu.flywheel.light.LightUpdater;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
|
@ -40,10 +40,10 @@ public class ForgeEvents {
|
|||
|
||||
@SubscribeEvent
|
||||
public static void onLoadWorld(WorldEvent.Load event) {
|
||||
IWorld world = event.getWorld();
|
||||
LevelAccessor world = event.getWorld();
|
||||
|
||||
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 net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraftforge.eventbus.api.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;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ClientWorld getWorld() {
|
||||
public ClientLevel getWorld() {
|
||||
return world;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,26 +4,26 @@ import javax.annotation.Nullable;
|
|||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
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.RenderTypeBuffers;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.client.renderer.RenderBuffers;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class RenderLayerEvent extends Event {
|
||||
private final ClientWorld world;
|
||||
private final ClientLevel world;
|
||||
public final RenderType type;
|
||||
public final MatrixStack stack;
|
||||
public final PoseStack stack;
|
||||
public final Matrix4f viewProjection;
|
||||
public final RenderTypeBuffers buffers;
|
||||
public final RenderBuffers buffers;
|
||||
public final double camX;
|
||||
public final double camY;
|
||||
public final double camZ;
|
||||
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.type = type;
|
||||
this.stack = stack;
|
||||
|
@ -47,7 +47,7 @@ public class RenderLayerEvent extends Event {
|
|||
return layer;
|
||||
}
|
||||
|
||||
public ClientWorld getWorld() {
|
||||
public ClientLevel getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,28 +3,28 @@ package com.jozufozu.flywheel.light;
|
|||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import com.jozufozu.flywheel.backend.gl.GlTexture;
|
|||
import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
|
||||
import com.jozufozu.flywheel.backend.gl.versioned.RGPixelFormat;
|
||||
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
|
||||
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);
|
||||
bufferDirty = true;
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ package com.jozufozu.flywheel.light;
|
|||
|
||||
import com.jozufozu.flywheel.util.RenderUtil;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.SectionPos;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.core.Vec3i;
|
||||
|
||||
public class GridAlignedBB implements ImmutableBox {
|
||||
private int minX;
|
||||
|
@ -33,7 +33,7 @@ public class GridAlignedBB implements ImmutableBox {
|
|||
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 minY = (int) Math.floor(aabb.minY);
|
||||
int minZ = (int) Math.floor(aabb.minZ);
|
||||
|
@ -77,7 +77,7 @@ public class GridAlignedBB implements ImmutableBox {
|
|||
this.maxZ = maxZ;
|
||||
}
|
||||
|
||||
public void translate(Vector3i by) {
|
||||
public void translate(Vec3i by) {
|
||||
translate(by.getX(), by.getY(), by.getZ());
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class GridAlignedBB implements ImmutableBox {
|
|||
}
|
||||
|
||||
public void mirrorAbout(Direction.Axis axis) {
|
||||
Vector3i axisVec = Direction.get(Direction.AxisDirection.POSITIVE, axis)
|
||||
Vec3i axisVec = Direction.get(Direction.AxisDirection.POSITIVE, axis)
|
||||
.getNormal();
|
||||
int flipX = axisVec.getX() - 1;
|
||||
int flipY = axisVec.getY() - 1;
|
||||
|
@ -176,7 +176,7 @@ public class GridAlignedBB implements ImmutableBox {
|
|||
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));
|
||||
minY = Math.min(this.minY, (int) Math.floor(other.minY));
|
||||
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));
|
||||
}
|
||||
|
||||
public void assign(AxisAlignedBB other) {
|
||||
public void assign(AABB other) {
|
||||
minX = (int) Math.floor(other.minX);
|
||||
minY = (int) Math.floor(other.minY);
|
||||
minZ = (int) Math.floor(other.minZ);
|
||||
|
@ -294,11 +294,11 @@ public class GridAlignedBB implements ImmutableBox {
|
|||
return this;
|
||||
}
|
||||
|
||||
public GridAlignedBB setMax(Vector3i v) {
|
||||
public GridAlignedBB setMax(Vec3i v) {
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,7 @@ public class GridAlignedBB implements ImmutableBox {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAs(AxisAlignedBB other) {
|
||||
public boolean sameAs(AABB other) {
|
||||
return minX == Math.floor(other.minX)
|
||||
&& minY == Math.floor(other.minY)
|
||||
&& minZ == Math.floor(other.minZ)
|
||||
|
@ -398,8 +398,8 @@ public class GridAlignedBB implements ImmutableBox {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB toAABB() {
|
||||
return new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
public AABB toAABB() {
|
||||
return new AABB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.jozufozu.flywheel.light;
|
||||
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
|
||||
public interface ILightUpdateListener {
|
||||
|
||||
|
@ -11,7 +11,7 @@ public interface ILightUpdateListener {
|
|||
/**
|
||||
* 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.
|
||||
|
@ -20,8 +20,8 @@ public interface ILightUpdateListener {
|
|||
default void onLightPacket(LightProvider world, int chunkX, int 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 net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
|
||||
public interface ImmutableBox {
|
||||
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();
|
||||
}
|
||||
|
||||
default boolean sameAs(AxisAlignedBB other) {
|
||||
default boolean sameAs(AABB other) {
|
||||
return getMinX() == Math.floor(other.minX)
|
||||
&& getMinY() == Math.floor(other.minY)
|
||||
&& getMinZ() == Math.floor(other.minZ)
|
||||
|
@ -119,8 +119,8 @@ public interface ImmutableBox {
|
|||
}
|
||||
}
|
||||
|
||||
default AxisAlignedBB toAABB() {
|
||||
return new AxisAlignedBB(getMinX(), getMinY(), getMinZ(), getMaxX(), getMaxY(), getMaxZ());
|
||||
default AABB toAABB() {
|
||||
return new AABB(getMinX(), getMinY(), getMinZ(), getMaxX(), getMaxY(), getMaxZ());
|
||||
}
|
||||
|
||||
default GridAlignedBB copy() {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package com.jozufozu.flywheel.light;
|
||||
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
|
||||
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) {
|
||||
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 it.unimi.dsi.fastutil.longs.LongSet;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.SectionPos;
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
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.
|
||||
*/
|
||||
public class LightUpdater {
|
||||
|
||||
private static final Map<IBlockDisplayReader, LightUpdater> light = new HashMap<>();
|
||||
public static LightUpdater get(IBlockDisplayReader world) {
|
||||
private static final Map<BlockAndTintGetter, LightUpdater> light = new HashMap<>();
|
||||
public static LightUpdater get(BlockAndTintGetter world) {
|
||||
return light.computeIfAbsent(world, LightUpdater::new);
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class LightUpdater {
|
|||
private final WeakContainmentMultiMap<ILightUpdateListener> sections = new WeakContainmentMultiMap<>();
|
||||
private final WeakContainmentMultiMap<ILightUpdateListener> chunks = new WeakContainmentMultiMap<>();
|
||||
|
||||
public LightUpdater(IBlockDisplayReader world) {
|
||||
public LightUpdater(BlockAndTintGetter world) {
|
||||
provider = BasicProvider.get(world);
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ public class LightUpdater {
|
|||
* @param type The type of light that 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);
|
||||
|
||||
if (set == null || set.isEmpty()) return;
|
||||
|
|
|
@ -4,8 +4,8 @@ import java.nio.ByteBuffer;
|
|||
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
|
||||
public class LightVolume implements ImmutableBox, ILightUpdateListener {
|
||||
|
||||
|
@ -66,15 +66,15 @@ public class LightVolume implements ImmutableBox, ILightUpdateListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onLightUpdate(LightProvider world, LightType type, ImmutableBox changedVolume) {
|
||||
public void onLightUpdate(LightProvider world, LightLayer type, ImmutableBox changedVolume) {
|
||||
if (lightData == null) return;
|
||||
|
||||
GridAlignedBB vol = changedVolume.copy();
|
||||
if (!vol.intersects(getVolume())) return;
|
||||
vol.intersectAssign(getVolume()); // compute the region contained by us that has dirty lighting data.
|
||||
|
||||
if (type == LightType.BLOCK) copyBlock(world, vol);
|
||||
else if (type == LightType.SKY) copySky(world, vol);
|
||||
if (type == LightLayer.BLOCK) copyBlock(world, vol);
|
||||
else if (type == LightLayer.SKY) copySky(world, vol);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -101,8 +101,8 @@ public class LightVolume implements ImmutableBox, ILightUpdateListener {
|
|||
int shiftZ = box.getMinZ();
|
||||
|
||||
box.forEachContained((x, y, z) -> {
|
||||
int blockLight = world.getLight(LightType.BLOCK, x, y, z);
|
||||
int skyLight = world.getLight(LightType.SKY, x, y, z);
|
||||
int blockLight = world.getLight(LightLayer.BLOCK, x, y, z);
|
||||
int skyLight = world.getLight(LightLayer.SKY, x, y, z);
|
||||
|
||||
writeLight(x - shiftX, y - shiftY, z - shiftZ, blockLight, skyLight);
|
||||
});
|
||||
|
@ -119,7 +119,7 @@ public class LightVolume implements ImmutableBox, ILightUpdateListener {
|
|||
int zShift = box.getMinZ();
|
||||
|
||||
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);
|
||||
});
|
||||
|
@ -136,7 +136,7 @@ public class LightVolume implements ImmutableBox, ILightUpdateListener {
|
|||
int zShift = box.getMinZ();
|
||||
|
||||
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);
|
||||
});
|
||||
|
@ -148,7 +148,7 @@ public class LightVolume implements ImmutableBox, ILightUpdateListener {
|
|||
* @param worldVolume the region in the world to copy data from.
|
||||
*/
|
||||
public void copyLight(LightProvider world, ImmutableBox worldVolume) {
|
||||
BlockPos.Mutable pos = new BlockPos.Mutable();
|
||||
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
|
||||
|
||||
int xShift = box.getMinX();
|
||||
int yShift = box.getMinY();
|
||||
|
@ -157,8 +157,8 @@ public class LightVolume implements ImmutableBox, ILightUpdateListener {
|
|||
worldVolume.forEachContained((x, y, z) -> {
|
||||
pos.set(x, y, z);
|
||||
|
||||
int block = world.getLight(LightType.BLOCK, x, y, z);
|
||||
int sky = world.getLight(LightType.SKY, x, y, z);
|
||||
int block = world.getLight(LightLayer.BLOCK, x, y, z);
|
||||
int sky = world.getLight(LightLayer.SKY, x, y, z);
|
||||
|
||||
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.instancing.InstancedRenderRegistry;
|
||||
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ClassInheritanceMultiMap;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.util.ClassInstanceMultiMap;
|
||||
|
||||
@Mixin(WorldRenderer.class)
|
||||
@Mixin(LevelRenderer.class)
|
||||
public class CancelEntityRenderMixin {
|
||||
|
||||
@Group(name = "entityFilter", min = 1, max = 1)
|
||||
@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();
|
||||
if (Backend.getInstance()
|
||||
.canUseInstancing()) {
|
||||
|
@ -39,7 +39,7 @@ public class CancelEntityRenderMixin {
|
|||
|
||||
@Group(name = "entityFilter")
|
||||
@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()
|
||||
.canUseInstancing()) {
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.jozufozu.flywheel.backend.Backend;
|
|||
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
||||
|
||||
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.OnlyIn;
|
||||
|
||||
|
@ -26,10 +26,10 @@ public class CancelTileEntityRenderMixin {
|
|||
* doing unnecessary light lookups and frustum checks.
|
||||
*/
|
||||
@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()
|
||||
.canUseInstancing()) {
|
||||
List<TileEntity> tiles = cir.getReturnValue();
|
||||
List<BlockEntity> tiles = cir.getReturnValue();
|
||||
|
||||
InstancedRenderRegistry r = InstancedRenderRegistry.getInstance();
|
||||
tiles.removeIf(r::shouldSkipRender);
|
||||
|
|
|
@ -12,34 +12,34 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientChunkProvider;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.world.biome.BiomeContainer;
|
||||
import net.minecraft.world.chunk.AbstractChunkProvider;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.ChunkStatus;
|
||||
import net.minecraft.world.chunk.IChunk;
|
||||
import net.minecraft.client.multiplayer.ClientChunkCache;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.level.chunk.ChunkBiomeContainer;
|
||||
import net.minecraft.world.level.chunk.ChunkSource;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
|
||||
@Mixin(ClientChunkProvider.class)
|
||||
public abstract class FastChunkProviderMixin extends AbstractChunkProvider {
|
||||
@Mixin(ClientChunkCache.class)
|
||||
public abstract class FastChunkProviderMixin extends ChunkSource {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private ClientWorld level;
|
||||
private ClientLevel level;
|
||||
@Unique
|
||||
private int lastX;
|
||||
@Unique
|
||||
private int lastZ;
|
||||
|
||||
@Unique
|
||||
private IChunk lastChunk;
|
||||
private ChunkAccess lastChunk;
|
||||
|
||||
@Inject(method = "getChunk",
|
||||
at = @At("HEAD"),
|
||||
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)) {
|
||||
synchronized (level) {
|
||||
if (lastChunk != null && x == lastX && z == lastZ) {
|
||||
|
@ -51,7 +51,7 @@ public abstract class FastChunkProviderMixin extends AbstractChunkProvider {
|
|||
|
||||
@Inject(method = "getChunk",
|
||||
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)) {
|
||||
synchronized (level) {
|
||||
lastChunk = cir.getReturnValue();
|
||||
|
@ -71,7 +71,7 @@ public abstract class FastChunkProviderMixin extends AbstractChunkProvider {
|
|||
}
|
||||
|
||||
@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) {
|
||||
synchronized (level) {
|
||||
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"))
|
||||
public boolean redirectTicking(ClientChunkProvider clientChunkProvider, int x, int z) {
|
||||
public boolean redirectTicking(ClientChunkCache clientChunkProvider, int x, int z) {
|
||||
if (Backend.getInstance().chunkCachingEnabled) {
|
||||
synchronized (level) {
|
||||
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.callback.CallbackInfo;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
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.LightTexture;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Mixin(WorldRenderer.class)
|
||||
@Mixin(LevelRenderer.class)
|
||||
public class FixFabulousDepthMixin {
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,37 +15,37 @@ import com.jozufozu.flywheel.core.crumbling.CrumblingRenderer;
|
|||
import com.jozufozu.flywheel.event.BeginFrameEvent;
|
||||
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
|
||||
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.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderTypeBuffers;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.culling.ClippingHelper;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.client.renderer.RenderBuffers;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Mixin(WorldRenderer.class)
|
||||
@Mixin(LevelRenderer.class)
|
||||
public class RenderHooksMixin {
|
||||
|
||||
@Shadow
|
||||
private ClientWorld level;
|
||||
private ClientLevel level;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private RenderTypeBuffers renderBuffers;
|
||||
private RenderBuffers renderBuffers;
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
|
@ -55,9 +55,9 @@ public class RenderHooksMixin {
|
|||
* This should probably be a forge event.
|
||||
*/
|
||||
@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));
|
||||
|
||||
|
@ -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
|
||||
), 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()
|
||||
.available()) return;
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class RenderHooksMixin {
|
|||
viewProjection.multiplyBackward(Backend.getInstance()
|
||||
.getProjectionMatrix());
|
||||
|
||||
Vector3d cameraPos = info.getPosition();
|
||||
Vec3 cameraPos = info.getPosition();
|
||||
CrumblingRenderer.renderBreaking(level, viewProjection, cameraPos.x, cameraPos.y, cameraPos.z);
|
||||
|
||||
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 net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.VideoSettingsScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.VideoSettingsScreen;
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
public class ShaderCloseMixin {
|
||||
|
|
|
@ -7,10 +7,10 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
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.util.math.vector.Matrix4f;
|
||||
import com.mojang.math.Matrix4f;
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public abstract class StoreProjectionMatrixMixin {
|
||||
|
@ -23,7 +23,7 @@ public abstract class StoreProjectionMatrixMixin {
|
|||
* 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"))
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,20 +10,20 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
|
||||
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
@Mixin(TileEntity.class)
|
||||
@Mixin(BlockEntity.class)
|
||||
public class TileRemoveMixin {
|
||||
|
||||
@Shadow
|
||||
@Nullable
|
||||
protected World level;
|
||||
protected Level level;
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "setRemoved")
|
||||
private void onRemove(CallbackInfo ci) {
|
||||
if (level instanceof ClientWorld) InstancedRenderDispatcher.getTiles(this.level)
|
||||
.remove((TileEntity) (Object) this);
|
||||
if (level instanceof ClientLevel) InstancedRenderDispatcher.getTiles(this.level)
|
||||
.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.InstancedRenderDispatcher;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@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 {
|
||||
|
||||
final World self = (World) (Object) this;
|
||||
final Level self = (Level) (Object) this;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
|
@ -30,10 +30,10 @@ public class TileWorldHookMixin {
|
|||
|
||||
@Shadow
|
||||
@Final
|
||||
protected Set<TileEntity> blockEntitiesToUnload;
|
||||
protected Set<BlockEntity> blockEntitiesToUnload;
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "addBlockEntity")
|
||||
private void onAddTile(TileEntity te, CallbackInfoReturnable<Boolean> cir) {
|
||||
private void onAddTile(BlockEntity te, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (isClientSide) {
|
||||
InstancedRenderDispatcher.getTiles(self)
|
||||
.queueAdd(te);
|
||||
|
@ -46,8 +46,8 @@ public class TileWorldHookMixin {
|
|||
@Inject(at = @At(value = "INVOKE", target = "Ljava/util/Set;clear()V", ordinal = 0), method = "tickBlockEntities")
|
||||
private void onChunkUnload(CallbackInfo ci) {
|
||||
if (isClientSide) {
|
||||
InstanceManager<TileEntity> kineticRenderer = InstancedRenderDispatcher.getTiles(self);
|
||||
for (TileEntity tile : blockEntitiesToUnload) {
|
||||
InstanceManager<BlockEntity> kineticRenderer = InstancedRenderDispatcher.getTiles(self);
|
||||
for (BlockEntity tile : blockEntitiesToUnload) {
|
||||
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