fix SkyAddon & end lantredom now has end sky
This commit is contained in:
parent
c761b96830
commit
c5a082f2fd
3 changed files with 35 additions and 31 deletions
|
@ -1,9 +1,8 @@
|
||||||
package org.dimdev.dimdoors.mixin.client;
|
package org.dimdev.dimdoors.mixin.client;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import org.dimdev.dimdoors.listener.pocket.PocketListenerUtil;
|
||||||
import org.dimdev.dimdoors.world.ModDimensions;
|
import org.dimdev.dimdoors.world.ModDimensions;
|
||||||
import org.dimdev.dimdoors.world.level.registry.DimensionalRegistry;
|
|
||||||
import org.dimdev.dimdoors.world.pocket.type.Pocket;
|
|
||||||
import org.dimdev.dimdoors.world.pocket.type.addon.SkyAddon;
|
import org.dimdev.dimdoors.world.pocket.type.addon.SkyAddon;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
@ -33,6 +32,8 @@ import net.minecraft.world.World;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Mixin(WorldRenderer.class)
|
@Mixin(WorldRenderer.class)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public abstract class WorldRendererMixin {
|
public abstract class WorldRendererMixin {
|
||||||
|
@ -51,10 +52,32 @@ public abstract class WorldRendererMixin {
|
||||||
@Final
|
@Final
|
||||||
private static Identifier END_SKY;
|
private static Identifier END_SKY;
|
||||||
|
|
||||||
@Shadow protected abstract void renderEndSky(MatrixStack matrices);
|
@Shadow
|
||||||
|
protected abstract void renderEndSky(MatrixStack matrices);
|
||||||
|
|
||||||
@Inject(method = "renderSky", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "renderSky", at = @At("HEAD"), cancellable = true)
|
||||||
public void beforeRenderSky(MatrixStack matrices, Matrix4f matrix4f, float f, Runnable runnable, CallbackInfo ci) {
|
public void beforeRenderSky(MatrixStack matrices, Matrix4f matrix4f, float f, Runnable runnable, CallbackInfo ci) {
|
||||||
|
List<SkyAddon> skyAddons = PocketListenerUtil.applicableAddonsClient(SkyAddon.class, this.world, this.client.gameRenderer.getCamera().getBlockPos());
|
||||||
|
SkyAddon skyAddon = null;
|
||||||
|
if (skyAddons.size() > 0) {
|
||||||
|
// There should really only be one of these.
|
||||||
|
// If anyone needs to use multiple SkyAddons then go ahead and change this.
|
||||||
|
skyAddon = skyAddons.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skyAddon != null) {
|
||||||
|
RegistryKey<World> world = skyAddon.getWorld();
|
||||||
|
|
||||||
|
if (world.equals(World.END)) {
|
||||||
|
this.renderEndSky(matrices);
|
||||||
|
ci.cancel();
|
||||||
|
return;
|
||||||
|
} else if (world.equals(ModDimensions.LIMBO)) {
|
||||||
|
this.renderLimboSky(matrices);
|
||||||
|
ci.cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (ModDimensions.isLimboDimension(this.world)) {
|
if (ModDimensions.isLimboDimension(this.world)) {
|
||||||
renderLimboSky(matrices);
|
renderLimboSky(matrices);
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
|
@ -62,23 +85,6 @@ public abstract class WorldRendererMixin {
|
||||||
this.renderPocketSky(matrices, 255, 255, 255);
|
this.renderPocketSky(matrices, 255, 255, 255);
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
} else if (ModDimensions.isPocketDimension(this.world)) {
|
} else if (ModDimensions.isPocketDimension(this.world)) {
|
||||||
Pocket pocket = DimensionalRegistry.getPocketDirectory(this.world.getRegistryKey()).getPocketAt(client.player.getBlockPos());
|
|
||||||
|
|
||||||
if(pocket != null && pocket.hasAddon(SkyAddon.ID)) {
|
|
||||||
RegistryKey<World> world = pocket.<SkyAddon>getAddon(SkyAddon.ID).getWorld();
|
|
||||||
|
|
||||||
if(world.equals(World.END)) {
|
|
||||||
this.renderEndSky(matrices);
|
|
||||||
ci.cancel();
|
|
||||||
} else if(world.equals(ModDimensions.LIMBO)) {
|
|
||||||
this.renderLimboSky(matrices);
|
|
||||||
ci.cancel();
|
|
||||||
} else if(ModDimensions.isPocketDimension(world)) {
|
|
||||||
this.renderPocketSky(matrices, 255, 255, 255);
|
|
||||||
ci.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.renderPocketSky(matrices, 0, 0, 0);
|
this.renderPocketSky(matrices, 0, 0, 0);
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package org.dimdev.dimdoors.world.pocket.type.addon;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.network.PacketByteBuf;
|
import net.minecraft.network.PacketByteBuf;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
@ -11,18 +10,12 @@ import net.minecraft.util.registry.RegistryKey;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import org.dimdev.dimdoors.world.pocket.type.Pocket;
|
import org.dimdev.dimdoors.world.pocket.type.Pocket;
|
||||||
import org.dimdev.dimdoors.world.pocket.type.PrivatePocket;
|
|
||||||
|
|
||||||
public class SkyAddon implements AutoSyncedAddon {
|
public class SkyAddon implements AutoSyncedAddon {
|
||||||
public static Identifier ID = new Identifier("dimdoors", "sky");
|
public static Identifier ID = new Identifier("dimdoors", "sky");
|
||||||
|
|
||||||
private RegistryKey<World> world;
|
private RegistryKey<World> world;
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applicable(Pocket pocket) {
|
|
||||||
return pocket instanceof PrivatePocket;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setWorld(RegistryKey<World> world) {
|
public boolean setWorld(RegistryKey<World> world) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
return true;
|
return true;
|
||||||
|
@ -82,7 +75,6 @@ public class SkyAddon implements AutoSyncedAddon {
|
||||||
public static class SkyBuilderAddon implements PocketBuilderAddon<SkyAddon> {
|
public static class SkyBuilderAddon implements PocketBuilderAddon<SkyAddon> {
|
||||||
|
|
||||||
private RegistryKey<World> world = World.OVERWORLD;
|
private RegistryKey<World> world = World.OVERWORLD;
|
||||||
// TODO: add some Pocket#init so that we can have boolean shouldRepaintOnInit
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(Pocket pocket) {
|
public void apply(Pocket pocket) {
|
||||||
|
|
|
@ -2,7 +2,13 @@
|
||||||
"type": "dimdoors:schematic",
|
"type": "dimdoors:schematic",
|
||||||
"id": "dungeon/lantredom_end",
|
"id": "dungeon/lantredom_end",
|
||||||
"builder": {
|
"builder": {
|
||||||
"type": "dimdoors:lazy_gen_pocket"
|
"type": "dimdoors:lazy_gen_pocket",
|
||||||
|
"addons": [
|
||||||
|
{
|
||||||
|
"type": "dimdoors:sky",
|
||||||
|
"world": "minecraft:the_end"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"modifiers": [
|
"modifiers": [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue