Merge branch 'DimensionalDevelopment:1.17' into 1.17
This commit is contained in:
commit
bde341f406
5 changed files with 172 additions and 6 deletions
|
@ -16,8 +16,8 @@ public final class GridUtil {
|
|||
}
|
||||
|
||||
public GridPos(BlockPos pos, int gridSize) {
|
||||
this.x = pos.getX() / gridSize / 16;
|
||||
this.z = pos.getZ() / gridSize / 16;
|
||||
this.x = Math.floorDiv(Math.floorDiv(pos.getX(), gridSize), 16);
|
||||
this.z = Math.floorDiv(Math.floorDiv(pos.getZ(), gridSize), 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.dimdev.dimdoors.mixin.client;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import org.dimdev.dimdoors.listener.pocket.PocketListenerUtil;
|
||||
import org.dimdev.dimdoors.world.ModDimensions;
|
||||
import org.dimdev.dimdoors.world.pocket.type.addon.SkyAddon;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -10,6 +12,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.BufferBuilder;
|
||||
import net.minecraft.client.render.BufferRenderer;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
|
@ -22,13 +25,18 @@ import net.minecraft.client.world.ClientWorld;
|
|||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import net.minecraft.util.math.Vec3f;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(WorldRenderer.class)
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class WorldRendererMixin {
|
||||
public abstract class WorldRendererMixin {
|
||||
@Unique
|
||||
private static final Identifier MOON_RENDER_PATH = new Identifier("dimdoors:textures/other/limbo_moon.png");
|
||||
@Unique
|
||||
|
@ -37,12 +45,39 @@ public class WorldRendererMixin {
|
|||
@Shadow
|
||||
private ClientWorld world;
|
||||
|
||||
@Shadow
|
||||
private MinecraftClient client;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private static Identifier END_SKY;
|
||||
|
||||
@Shadow
|
||||
protected abstract void renderEndSky(MatrixStack matrices);
|
||||
|
||||
@Inject(method = "renderSky", at = @At("HEAD"), cancellable = true)
|
||||
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)) {
|
||||
renderLimboSky(matrices);
|
||||
ci.cancel();
|
||||
|
@ -73,7 +108,7 @@ public class WorldRendererMixin {
|
|||
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
||||
for(int i = 0; i < 6; ++i) {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
matrices.push();
|
||||
if (i == 1) {
|
||||
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90.0F));
|
||||
|
@ -136,7 +171,7 @@ public class WorldRendererMixin {
|
|||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder bufferBuilder = tessellator.getBuffer();
|
||||
|
||||
for(int i = 0; i < 6; ++i) {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
matrices.push();
|
||||
if (i == 1) {
|
||||
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90.0F));
|
||||
|
|
|
@ -84,6 +84,7 @@ public interface PocketAddon {
|
|||
PocketAddonType<DyeableAddon> DYEABLE_ADDON = register(DyeableAddon.ID, DyeableAddon::new, DyeableAddon.DyeableBuilderAddon::new);
|
||||
PocketAddonType<PreventBlockModificationAddon> PREVENT_BLOCK_MODIFICATION_ADDON = register(PreventBlockModificationAddon.ID, PreventBlockModificationAddon::new, PreventBlockModificationAddon.PreventBlockModificationBuilderAddon::new);
|
||||
PocketAddonType<BlockBreakContainer> BLOCK_BREAK_CONTAINER = register(BlockBreakContainer.ID, BlockBreakContainer::new, null);
|
||||
PocketAddonType<SkyAddon> SKY_ADDON = register(SkyAddon.ID, SkyAddon::new, SkyAddon.SkyBuilderAddon::new);
|
||||
|
||||
T fromNbt(NbtCompound nbt);
|
||||
|
||||
|
|
|
@ -0,0 +1,124 @@
|
|||
package org.dimdev.dimdoors.world.pocket.type.addon;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.dimdev.dimdoors.world.pocket.type.Pocket;
|
||||
|
||||
public class SkyAddon implements AutoSyncedAddon {
|
||||
public static Identifier ID = new Identifier("dimdoors", "sky");
|
||||
|
||||
private RegistryKey<World> world;
|
||||
|
||||
public boolean setWorld(RegistryKey<World> world) {
|
||||
this.world = world;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PocketAddon fromNbt(NbtCompound nbt) {
|
||||
this.world = RegistryKey.of(Registry.WORLD_KEY, Identifier.tryParse(nbt.getString("world")));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NbtCompound toNbt(NbtCompound nbt) {
|
||||
AutoSyncedAddon.super.toNbt(nbt);
|
||||
|
||||
nbt.putString("world", this.world.getValue().toString());
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PocketAddonType<? extends PocketAddon> getType() {
|
||||
return PocketAddonType.SKY_ADDON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public RegistryKey<World> getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AutoSyncedAddon read(PacketByteBuf buf) throws IOException {
|
||||
this.world = RegistryKey.of(Registry.WORLD_KEY, buf.readIdentifier());
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketByteBuf write(PacketByteBuf buf) throws IOException {
|
||||
buf.writeIdentifier(world.getValue());
|
||||
return buf;
|
||||
}
|
||||
|
||||
public interface SkyPocketBuilder<T extends Pocket.PocketBuilder<T, ?>> extends PocketBuilderExtension<T> {
|
||||
default T world(RegistryKey<World> world) {
|
||||
|
||||
this.<SkyBuilderAddon>getAddon(ID).world = world;
|
||||
|
||||
return getSelf();
|
||||
}
|
||||
}
|
||||
|
||||
public static class SkyBuilderAddon implements PocketBuilderAddon<SkyAddon> {
|
||||
|
||||
private RegistryKey<World> world = World.OVERWORLD;
|
||||
|
||||
@Override
|
||||
public void apply(Pocket pocket) {
|
||||
SkyAddon addon = new SkyAddon();
|
||||
addon.world = world;
|
||||
pocket.addAddon(addon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PocketBuilderAddon<SkyAddon> fromNbt(NbtCompound nbt) {
|
||||
this.world = RegistryKey.of(Registry.WORLD_KEY, Identifier.tryParse(nbt.getString("world")));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NbtCompound toNbt(NbtCompound nbt) {
|
||||
PocketBuilderAddon.super.toNbt(nbt);
|
||||
|
||||
nbt.putString("world", world.getValue().toString());
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PocketAddonType<SkyAddon> getType() {
|
||||
return PocketAddonType.SKY_ADDON;
|
||||
}
|
||||
}
|
||||
|
||||
public interface SkyPocket extends AddonProvider {
|
||||
default boolean sky(RegistryKey<World> world) {
|
||||
ensureIsPocket();
|
||||
if (!this.hasAddon(ID)) {
|
||||
SkyAddon addon = new SkyAddon();
|
||||
this.addAddon(addon);
|
||||
return addon.setWorld(world);
|
||||
}
|
||||
return this.<SkyAddon>getAddon(ID).setWorld(world);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,13 @@
|
|||
"type": "dimdoors:schematic",
|
||||
"id": "dungeon/lantredom_end",
|
||||
"builder": {
|
||||
"type": "dimdoors:lazy_gen_pocket"
|
||||
"type": "dimdoors:lazy_gen_pocket",
|
||||
"addons": [
|
||||
{
|
||||
"type": "dimdoors:sky",
|
||||
"world": "minecraft:the_end"
|
||||
}
|
||||
]
|
||||
},
|
||||
"modifiers": [
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue