diff --git a/common/src/main/java/org/dimdev/dimdoors/block/door/DimensionalDoorBlockRegistrar.java b/common/src/main/java/org/dimdev/dimdoors/block/door/DimensionalDoorBlockRegistrar.java index 067ef48f..fa544f5a 100644 --- a/common/src/main/java/org/dimdev/dimdoors/block/door/DimensionalDoorBlockRegistrar.java +++ b/common/src/main/java/org/dimdev/dimdoors/block/door/DimensionalDoorBlockRegistrar.java @@ -14,6 +14,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.DoorBlock; import net.minecraft.world.level.block.TrapDoorBlock; @@ -21,6 +22,7 @@ import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.storage.loot.LootParams; import org.dimdev.dimdoors.DimensionalDoors; import org.dimdev.dimdoors.block.DoorSoundProvider; import org.dimdev.dimdoors.block.entity.ModBlockEntityTypes; @@ -150,6 +152,11 @@ public class DimensionalDoorBlockRegistrar { throw new RuntimeException("AutoGenDimensionalDoorBlock should be instantiated as anonymous inner class overriding appendProperties!"); } + @Override + public List getDrops(BlockState state, LootParams.Builder params) { + return originalBlock.getDrops(state, params); + } + @Override public MutableComponent getName() { return Component.translatable("dimdoors.autogen_block_prefix", originalBlock.getName()); diff --git a/common/src/main/java/org/dimdev/dimdoors/block/entity/RiftBlockEntity.java b/common/src/main/java/org/dimdev/dimdoors/block/entity/RiftBlockEntity.java index dce24fdc..dc6e9125 100644 --- a/common/src/main/java/org/dimdev/dimdoors/block/entity/RiftBlockEntity.java +++ b/common/src/main/java/org/dimdev/dimdoors/block/entity/RiftBlockEntity.java @@ -193,8 +193,7 @@ public abstract class RiftBlockEntity extends BlockEntity implements Target, Ent BlockState state = this.getLevel().getBlockState(this.getBlockPos()); Block block = state.getBlock(); - if (block instanceof CoordinateTransformerBlock) { - CoordinateTransformerBlock transformer = (CoordinateTransformerBlock) block; + if (block instanceof CoordinateTransformerBlock transformer) { TransformationMatrix3d.TransformationMatrix3dBuilder transformationBuilder = transformer.transformationBuilder(state, this.getBlockPos()); TransformationMatrix3d.TransformationMatrix3dBuilder rotatorBuilder = transformer.rotatorBuilder(state, this.getBlockPos()); relativePos = transformer.transformTo(transformationBuilder, entity.position()); diff --git a/common/src/main/java/org/dimdev/dimdoors/client/effect/DungeonDimensionEffect.java b/common/src/main/java/org/dimdev/dimdoors/client/effect/DungeonDimensionEffect.java index f757cf6a..23116534 100644 --- a/common/src/main/java/org/dimdev/dimdoors/client/effect/DungeonDimensionEffect.java +++ b/common/src/main/java/org/dimdev/dimdoors/client/effect/DungeonDimensionEffect.java @@ -1,19 +1,21 @@ package org.dimdev.dimdoors.client.effect; +import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; +import com.mojang.math.Axis; import dev.architectury.injectables.annotations.ExpectPlatform; import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.client.renderer.DimensionSpecialEffects; -import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.client.renderer.LightTexture; +import net.minecraft.client.renderer.*; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; import net.minecraft.world.entity.vehicle.Minecart; import net.minecraft.world.level.Level; import net.minecraft.world.level.dimension.BuiltinDimensionTypes; +import net.minecraft.world.level.material.FogType; import net.minecraft.world.phys.Vec3; import org.dimdev.dimdoors.DimensionalDoors; import org.dimdev.dimdoors.listener.pocket.PocketListenerUtil; @@ -58,13 +60,15 @@ public class DungeonDimensionEffect extends DimensionSpecialEffects implements D if (key.equals(BuiltinDimensionTypes.END_EFFECTS)) { renderEndSky(poseStack); - } else if (DimensionSpecialEffectsMixin.getEffects().containsKey(key)) { + } else if(key.equals(BuiltinDimensionTypes.OVERWORLD_EFFECTS)) { + renderOverworld(skyAddon, poseStack, projectionMatrix, partialTick, isFoggy, setupFog); + } /*else if (DimensionSpecialEffectsMixin.getEffects().containsKey(key)) { var effects = DimensionSpecialEffectsMixin.getEffects().get(key); if (effects != null) { renderEffect(effects, level, ticks, partialTick, poseStack, camera, projectionMatrix, isFoggy, setupFog); } - } + }*/ } return true; @@ -119,6 +123,117 @@ public class DungeonDimensionEffect extends DimensionSpecialEffects implements D RenderSystem.disableBlend(); } + public void renderOverworld(SkyAddon info, PoseStack poseStack, Matrix4f projectionMatrix, float partialTick, boolean isFoggy, Runnable skyFogSetup) { + float q; + float p; + float o; + int m; + float k; + float i; + + var levelRenderer = Minecraft.getInstance().levelRenderer; + + skyFogSetup.run(); + if (isFoggy) { + return; + } + + FogRenderer.levelFogColor(); + BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder(); + RenderSystem.depthMask(false); + float g = Mth.cos(info.getTimeOfDay() * ((float)Math.PI * 2)) * 2.0f + 0.5f; + g = Mth.clamp(g, 0.0f, 1.0f); + RenderSystem.setShaderColor(0.529f * g, 0.808f * g, 0.922f * g, 1.0f); //sky color + ShaderInstance shaderInstance = RenderSystem.getShader(); + levelRenderer.skyBuffer.bind(); + levelRenderer.skyBuffer.drawWithShader(poseStack.last().pose(), projectionMatrix, shaderInstance); + VertexBuffer.unbind(); + RenderSystem.enableBlend(); + var level = Minecraft.getInstance().level; + float[] fs = getSunriseColor(info.getTimeOfDay(), partialTick); + + if (fs != null) { + RenderSystem.setShader(GameRenderer::getPositionColorShader); + RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); + poseStack.pushPose(); + poseStack.mulPose(Axis.XP.rotationDegrees(90.0f)); + i = Mth.sin(info.getSunAngle()) < 0.0f ? 180.0f : 0.0f; + poseStack.mulPose(Axis.ZP.rotationDegrees(i)); + poseStack.mulPose(Axis.ZP.rotationDegrees(90.0f)); + float j = fs[0]; + k = fs[1]; + float l = fs[2]; + Matrix4f matrix4f = poseStack.last().pose(); + bufferBuilder.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR); + bufferBuilder.vertex(matrix4f, 0.0f, 100.0f, 0.0f).color(j, k, l, fs[3]).endVertex(); + m = 16; + for (int n = 0; n <= 16; ++n) { + o = (float)n * ((float)Math.PI * 2) / 16.0f; + p = Mth.sin(o); + q = Mth.cos(o); + bufferBuilder.vertex(matrix4f, p * 120.0f, q * 120.0f, -q * 40.0f * fs[3]).color(fs[0], fs[1], fs[2], 0.0f).endVertex(); + } + BufferUploader.drawWithShader(bufferBuilder.end()); + poseStack.popPose(); + } + RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); + poseStack.pushPose(); +// i = 1.0f - 0; //level.getRainLevel(partialTick); TODO: Find out if we want this + RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1); + poseStack.mulPose(Axis.YP.rotationDegrees(-90.0f)); + poseStack.mulPose(Axis.XP.rotationDegrees(info.getTimeOfDay() * 360.0f)); + Matrix4f matrix4f2 = poseStack.last().pose(); + k = 30.0f; + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderTexture(0, LevelRenderer.SUN_LOCATION); + bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); + bufferBuilder.vertex(matrix4f2, -k, 100.0f, -k).uv(0.0f, 0.0f).endVertex(); + bufferBuilder.vertex(matrix4f2, k, 100.0f, -k).uv(1.0f, 0.0f).endVertex(); + bufferBuilder.vertex(matrix4f2, k, 100.0f, k).uv(1.0f, 1.0f).endVertex(); + bufferBuilder.vertex(matrix4f2, -k, 100.0f, k).uv(0.0f, 1.0f).endVertex(); + BufferUploader.drawWithShader(bufferBuilder.end()); + k = 20.0f; + RenderSystem.setShaderTexture(0, LevelRenderer.MOON_LOCATION); + int r = info.getMoonPhase(); + int s = r % 4; + m = r / 4 % 2; + float t = (float)(s) / 4.0f; + o = (float)(m) / 2.0f; + p = (float)(s + 1) / 4.0f; + q = (float)(m + 1) / 2.0f; + bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); + bufferBuilder.vertex(matrix4f2, -k, -100.0f, k).uv(p, q).endVertex(); + bufferBuilder.vertex(matrix4f2, k, -100.0f, k).uv(t, q).endVertex(); + bufferBuilder.vertex(matrix4f2, k, -100.0f, -k).uv(t, o).endVertex(); + bufferBuilder.vertex(matrix4f2, -k, -100.0f, -k).uv(p, o).endVertex(); + BufferUploader.drawWithShader(bufferBuilder.end()); + float u = info.getStarBrightness(); + if (u > 0.0f) { + RenderSystem.setShaderColor(u, u, u, u); + FogRenderer.setupNoFog(); + levelRenderer.starBuffer.bind(); + levelRenderer.starBuffer.drawWithShader(poseStack.last().pose(), projectionMatrix, GameRenderer.getPositionShader()); + VertexBuffer.unbind(); + skyFogSetup.run(); + } + RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); + RenderSystem.disableBlend(); + RenderSystem.defaultBlendFunc(); + poseStack.popPose(); + RenderSystem.setShaderColor(0.0f, 0.0f, 0.0f, 1.0f); + double d = Minecraft.getInstance().player.getEyePosition((float)partialTick).y - level.getLevelData().getHorizonHeight(Minecraft.getInstance().level); + if (d < 0.0) { + poseStack.pushPose(); + poseStack.translate(0.0f, 12.0f, 0.0f); + levelRenderer.darkBuffer.bind(); + levelRenderer.darkBuffer.drawWithShader(poseStack.last().pose(), projectionMatrix, shaderInstance); + VertexBuffer.unbind(); + poseStack.popPose(); + } + RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); + RenderSystem.depthMask(true); + } + @Override public boolean renderClouds(ClientLevel level, int ticks, float partialTick, PoseStack poseStack, double camX, double camY, double camZ, Matrix4f projectionMatrix) { return true; @@ -128,4 +243,6 @@ public class DungeonDimensionEffect extends DimensionSpecialEffects implements D public boolean renderSnowAndRain(ClientLevel level, int ticks, float partialTick, LightTexture lightTexture, double camX, double camY, double camZ) { return true; } + + } diff --git a/common/src/main/java/org/dimdev/dimdoors/pockets/PocketGenerator.java b/common/src/main/java/org/dimdev/dimdoors/pockets/PocketGenerator.java index 90e496dc..81321c8c 100644 --- a/common/src/main/java/org/dimdev/dimdoors/pockets/PocketGenerator.java +++ b/common/src/main/java/org/dimdev/dimdoors/pockets/PocketGenerator.java @@ -49,6 +49,12 @@ public final class PocketGenerator { return generatePocketV2(PocketLoader.getInstance().getGroup(group).getNextPocketGeneratorReference(context), context); } + public static Pocket generateFromVirtualPocket(ServerLevel world, ResourceLocation id, VirtualLocation virtualLocation, VirtualTarget linkTo, LinkProperties linkProperties) { + PocketGenerationContext context = new PocketGenerationContext(world, virtualLocation, linkTo, linkProperties); + LOGGER.info("Generating virtual target: " + id); + return generatePocketV2(PocketLoader.getInstance().getVirtual(id).getNextPocketGeneratorReference(context), context); + } + public static Pocket generatePocketV2(PocketGeneratorReference pocketGeneratorReference, PocketGenerationContext context) { return pocketGeneratorReference.prepareAndPlacePocket(context); } diff --git a/common/src/main/java/org/dimdev/dimdoors/pockets/PocketLoader.java b/common/src/main/java/org/dimdev/dimdoors/pockets/PocketLoader.java index f8a56717..82865f89 100644 --- a/common/src/main/java/org/dimdev/dimdoors/pockets/PocketLoader.java +++ b/common/src/main/java/org/dimdev/dimdoors/pockets/PocketLoader.java @@ -112,6 +112,11 @@ public class PocketLoader implements ResourceManagerReloadListener { return pocketGroups.get(Path.stringPath(group)); } + public VirtualPocket getVirtual(ResourceLocation id) { + return virtualPockets.get(Path.stringPath(id)); + } + + public static PocketLoader getInstance() { return INSTANCE; } diff --git a/common/src/main/java/org/dimdev/dimdoors/pockets/modifier/Modifier.java b/common/src/main/java/org/dimdev/dimdoors/pockets/modifier/Modifier.java index a9e3fb44..5aecee8b 100644 --- a/common/src/main/java/org/dimdev/dimdoors/pockets/modifier/Modifier.java +++ b/common/src/main/java/org/dimdev/dimdoors/pockets/modifier/Modifier.java @@ -98,6 +98,8 @@ public interface Modifier extends ReferenceSerializable { RegistrySupplier> OFFSET_MODIFIER_TYPE = register(DimensionalDoors.id(OffsetModifier.KEY), OffsetModifier::new); RegistrySupplier> ABSOLUTE_RIFT_BLOCK_ENTITY_MODIFIER_TYPE = register(DimensionalDoors.id(AbsoluteRiftBlockEntityModifier.KEY), AbsoluteRiftBlockEntityModifier::new); + RegistrySupplier> TEMPLATE_MODIFIER_TYPE = register(DimensionalDoors.id(TemplateModifier.KEY), TemplateModifier::new); + Modifier fromNbt(CompoundTag nbt, ResourceManager manager); default Modifier fromNbt(CompoundTag nbt) { diff --git a/common/src/main/java/org/dimdev/dimdoors/pockets/modifier/RiftDataModifier.java b/common/src/main/java/org/dimdev/dimdoors/pockets/modifier/RiftDataModifier.java index 2770fddf..fce50b5c 100644 --- a/common/src/main/java/org/dimdev/dimdoors/pockets/modifier/RiftDataModifier.java +++ b/common/src/main/java/org/dimdev/dimdoors/pockets/modifier/RiftDataModifier.java @@ -45,7 +45,7 @@ public class RiftDataModifier extends AbstractModifier { return IntStream.generate(buffer::get).limit(buffer.remaining()); } - private static byte[] toByteArray(int[] ints) { + public static byte[] toByteArray(int[] ints) { byte[] bytes = new byte[ints.length]; for (int i = 0; i < ints.length; i++) { bytes[i] = (byte) ints[i]; diff --git a/common/src/main/java/org/dimdev/dimdoors/pockets/modifier/TemplateModifier.java b/common/src/main/java/org/dimdev/dimdoors/pockets/modifier/TemplateModifier.java new file mode 100644 index 00000000..70d2a14d --- /dev/null +++ b/common/src/main/java/org/dimdev/dimdoors/pockets/modifier/TemplateModifier.java @@ -0,0 +1,75 @@ +package org.dimdev.dimdoors.pockets.modifier; + +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.resources.ResourceManager; +import org.dimdev.dimdoors.block.entity.RiftBlockEntity; +import org.dimdev.dimdoors.pockets.PocketGenerationContext; +import org.dimdev.dimdoors.rift.targets.TemplateTarget; +import org.dimdev.dimdoors.world.pocket.type.Pocket; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.IntConsumer; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +import static org.dimdev.dimdoors.pockets.modifier.RiftDataModifier.stream; +import static org.dimdev.dimdoors.pockets.modifier.RiftDataModifier.toByteArray; + +public class TemplateModifier extends AbstractModifier { + public static final String KEY = "template"; + + private ResourceLocation templateId; + + private List ids; + + @Override + public Modifier fromNbt(CompoundTag nbt, ResourceManager manager) { + templateId = ResourceLocation.tryParse(nbt.getString("templateId")); + ids = stream(nbt.getByteArray("ids")).boxed().collect(Collectors.toList()); + return this; + } + + @Override + public CompoundTag toNbtInternal(CompoundTag nbt, boolean allowReference) { + super.toNbtInternal(nbt, allowReference); + + nbt.putString("templateId", templateId.toString()); + nbt.putByteArray("ids", toByteArray(ids.stream().mapToInt(Integer::intValue).toArray())); + return nbt; + } + + + @Override + public ModifierType getType() { + return ModifierType.TEMPLATE_MODIFIER_TYPE.get(); + } + + @Override + public String getKey() { + return KEY; + } + + @Override + public void apply(PocketGenerationContext parameters, RiftManager manager) { + var template = new TemplateTarget(templateId); + + manager.foreachConsume((id, rift) -> { + if(ids.contains(id)) { + rift.setDestination(template.copy()); + return true; + } else { + return false; + } + }); + } + + @Override + public void apply(PocketGenerationContext parameters, Pocket.PocketBuilder builder) { + + } +} diff --git a/common/src/main/java/org/dimdev/dimdoors/rift/targets/PublicPocketTarget.java b/common/src/main/java/org/dimdev/dimdoors/rift/targets/PublicPocketTarget.java index 66f3216a..5458fd9b 100644 --- a/common/src/main/java/org/dimdev/dimdoors/rift/targets/PublicPocketTarget.java +++ b/common/src/main/java/org/dimdev/dimdoors/rift/targets/PublicPocketTarget.java @@ -7,24 +7,14 @@ import org.dimdev.dimdoors.world.level.registry.DimensionalRegistry; import org.dimdev.dimdoors.world.pocket.VirtualLocation; import org.dimdev.dimdoors.world.pocket.type.Pocket; -public class PublicPocketTarget extends RestoringTarget { - private VirtualTarget wrappedDestination = null; +public class PublicPocketTarget extends WrappedDestinationTarget { private PublicPocketTarget(VirtualTarget wrappedDestination) { - this.wrappedDestination = wrappedDestination; + super(wrappedDestination); } public PublicPocketTarget() { - } - - @Override - protected VirtualTarget getTarget() { - return this.wrappedDestination; - } - - @Override - protected void setTarget(VirtualTarget target) { - this.wrappedDestination = target; + super(); } @Override @@ -49,16 +39,10 @@ public class PublicPocketTarget extends RestoringTarget { } public static CompoundTag toNbt(PublicPocketTarget target) { - CompoundTag nbt = new CompoundTag(); - if (target.wrappedDestination != null) - nbt.put("wrappedDestination", VirtualTarget.toNbt(target.wrappedDestination)); - return nbt; + return WrappedDestinationTarget.toNbt(target); } public static PublicPocketTarget fromNbt(CompoundTag nbt) { - PublicPocketTarget target = new PublicPocketTarget(); - if (nbt.contains("wrappedDestination")) - target.wrappedDestination = VirtualTarget.fromNbt(nbt.getCompound("wrappedDestination")); - return target; + return fromNbt(nbt, new PublicPocketTarget()); } } diff --git a/common/src/main/java/org/dimdev/dimdoors/rift/targets/TemplateTarget.java b/common/src/main/java/org/dimdev/dimdoors/rift/targets/TemplateTarget.java new file mode 100644 index 00000000..c97fa672 --- /dev/null +++ b/common/src/main/java/org/dimdev/dimdoors/rift/targets/TemplateTarget.java @@ -0,0 +1,62 @@ +package org.dimdev.dimdoors.rift.targets; + +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; +import org.dimdev.dimdoors.DimensionalDoors; +import org.dimdev.dimdoors.api.util.Location; +import org.dimdev.dimdoors.pockets.PocketGenerator; +import org.dimdev.dimdoors.rift.registry.LinkProperties; +import org.dimdev.dimdoors.world.ModDimensions; +import org.dimdev.dimdoors.world.level.registry.DimensionalRegistry; +import org.dimdev.dimdoors.world.pocket.VirtualLocation; +import org.dimdev.dimdoors.world.pocket.type.Pocket; + +import java.util.Arrays; +import java.util.Set; +import java.util.stream.Collectors; + +public class TemplateTarget extends WrappedDestinationTarget { + private final ResourceLocation template; + + public TemplateTarget(VirtualTarget wrappedDestination, ResourceLocation template) { + super(wrappedDestination); + this.template = template; + } + + public TemplateTarget(ResourceLocation template) { + this(null, template); + } + + @Override + public Location makeLinkTarget() { + VirtualLocation riftVirtualLocation = VirtualLocation.fromLocation(this.location); + VirtualLocation newVirtualLocation; + int depth = riftVirtualLocation.getDepth() + 1; + newVirtualLocation = new VirtualLocation(riftVirtualLocation.getWorld(), riftVirtualLocation.getX(), riftVirtualLocation.getZ(), depth); + Pocket pocket = PocketGenerator.generateFromVirtualPocket(DimensionalDoors.getWorld(ModDimensions.DUNGEON), template, newVirtualLocation, new GlobalReference(this.location), null); + + return DimensionalRegistry.getRiftRegistry().getPocketEntrance(pocket); + } + + public static CompoundTag toNbt(TemplateTarget target) { + CompoundTag nbt = WrappedDestinationTarget.toNbt(target); + + nbt.putString("template", target.template.toString()); + + return nbt; + } + + @Override + public VirtualTarget copy() { + return new TemplateTarget(wrappedDestination, template); + } + public static TemplateTarget fromNbt(CompoundTag nbt) { + var id = ResourceLocation.tryParse(nbt.getString("template")); + return fromNbt(nbt, new TemplateTarget(id)); + } + + @Override + public VirtualTargetType getType() { + return VirtualTargetType.TEMPLATE.get(); + } +} diff --git a/common/src/main/java/org/dimdev/dimdoors/rift/targets/VirtualTarget.java b/common/src/main/java/org/dimdev/dimdoors/rift/targets/VirtualTarget.java index 7c4e2f83..07d51e20 100644 --- a/common/src/main/java/org/dimdev/dimdoors/rift/targets/VirtualTarget.java +++ b/common/src/main/java/org/dimdev/dimdoors/rift/targets/VirtualTarget.java @@ -86,6 +86,7 @@ public abstract class VirtualTarget implements Target { public interface VirtualTargetType { RegistrySupplier> AVAILABLE_LINK = register("dimdoors:available_link", RandomTarget::fromNbt, RandomTarget::toNbt, VirtualTarget.COLOR); RegistrySupplier> DUNGEON = register("dimdoors:dungeon", DungeonTarget::fromNbt, DungeonTarget::toNbt, VirtualTarget.COLOR); + RegistrySupplier> TEMPLATE = register("dimdoors:template", TemplateTarget::fromNbt, TemplateTarget::toNbt, VirtualTarget.COLOR); RegistrySupplier> ESCAPE = register("dimdoors:escape", EscapeTarget::fromNbt, EscapeTarget::toNbt, VirtualTarget.COLOR); RegistrySupplier> GLOBAL = register("dimdoors:global", GlobalReference::fromNbt, GlobalReference::toNbt, VirtualTarget.COLOR); RegistrySupplier> LIMBO = register("dimdoors:limbo", a -> LimboTarget.INSTANCE, a -> new CompoundTag(), VirtualTarget.COLOR); diff --git a/common/src/main/java/org/dimdev/dimdoors/rift/targets/WrappedDestinationTarget.java b/common/src/main/java/org/dimdev/dimdoors/rift/targets/WrappedDestinationTarget.java new file mode 100644 index 00000000..1f0ab4ac --- /dev/null +++ b/common/src/main/java/org/dimdev/dimdoors/rift/targets/WrappedDestinationTarget.java @@ -0,0 +1,43 @@ +package org.dimdev.dimdoors.rift.targets; + +import net.minecraft.nbt.CompoundTag; +import org.dimdev.dimdoors.api.util.Location; +import org.dimdev.dimdoors.pockets.PocketGenerator; +import org.dimdev.dimdoors.world.level.registry.DimensionalRegistry; +import org.dimdev.dimdoors.world.pocket.VirtualLocation; +import org.dimdev.dimdoors.world.pocket.type.Pocket; + +public abstract class WrappedDestinationTarget extends RestoringTarget { + protected VirtualTarget wrappedDestination = null; + + public WrappedDestinationTarget(VirtualTarget wrappedDestination) { + this.wrappedDestination = wrappedDestination; + } + + public WrappedDestinationTarget() { + } + + @Override + protected VirtualTarget getTarget() { + return this.wrappedDestination; + } + + @Override + protected void setTarget(VirtualTarget target) { + this.wrappedDestination = target; + } + + public static CompoundTag toNbt(WrappedDestinationTarget target) { + CompoundTag nbt = new CompoundTag(); + if (target.wrappedDestination != null) + nbt.put("wrappedDestination", VirtualTarget.toNbt(target.wrappedDestination)); + return nbt; + } + + + public static T fromNbt(CompoundTag nbt, T target) { + if (nbt.contains("wrappedDestination")) + target.wrappedDestination = VirtualTarget.fromNbt(nbt.getCompound("wrappedDestination")); + return target; + } +} diff --git a/common/src/main/java/org/dimdev/dimdoors/world/pocket/type/addon/SkyAddon.java b/common/src/main/java/org/dimdev/dimdoors/world/pocket/type/addon/SkyAddon.java index 84f0e2eb..2dfe46ea 100644 --- a/common/src/main/java/org/dimdev/dimdoors/world/pocket/type/addon/SkyAddon.java +++ b/common/src/main/java/org/dimdev/dimdoors/world/pocket/type/addon/SkyAddon.java @@ -6,8 +6,12 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.CubicSampler; +import net.minecraft.util.Mth; +import net.minecraft.world.level.biome.BiomeManager; import net.minecraft.world.level.dimension.BuiltinDimensionTypes; import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.phys.Vec3; import org.dimdev.dimdoors.DimensionalDoors; import org.dimdev.dimdoors.mixin.client.accessor.DimensionSpecialEffectsMixin; import org.dimdev.dimdoors.world.pocket.type.Pocket; @@ -17,17 +21,30 @@ public class SkyAddon implements AutoSyncedAddon { private ResourceLocation effect; + private long dayTime = 6000L; + private byte moonPhase; + public boolean setEfffect(ResourceLocation effect) { this.effect = effect; return true; } + public void setDayTime(long dayTime) { + this.dayTime = dayTime; + } + + public void setMoonPhase(byte moonPhase) { + this.moonPhase = moonPhase; + } + + @Override public PocketAddon fromNbt(CompoundTag nbt) { ResourceLocation tag = null; this.effect = !nbt.contains("effect") && nbt.contains("world") ? ResourceLocation.tryParse(nbt.getString("world")) : nbt.contains("effect") ? ResourceLocation.tryParse(nbt.getString("effect")) : null; - + this.dayTime = nbt.contains("dayTime") ? nbt.getLong("dayTime") : 12000L; + this.moonPhase = nbt.contains("moonPhase") ? nbt.getByte("moonPhase") : 0; return this; } @@ -36,6 +53,8 @@ public class SkyAddon implements AutoSyncedAddon { AutoSyncedAddon.super.toNbt(nbt); nbt.putString("effect", this.effect.toString()); + nbt.putLong("dayTime", this.dayTime); + nbt.putByte("moonPhase", this.moonPhase); return nbt; } @@ -57,15 +76,20 @@ public class SkyAddon implements AutoSyncedAddon { @Override public AutoSyncedAddon read(FriendlyByteBuf buf) { this.effect = buf.readResourceLocation(); + this.dayTime = buf.readLong(); + this.moonPhase = buf.readByte(); return this; } @Override public FriendlyByteBuf write(FriendlyByteBuf buf) { buf.writeResourceLocation(effect); + buf.writeLong(dayTime); + buf.writeByte(moonPhase); return buf; } + public interface SkyPocketBuilder> extends PocketBuilderExtension { default T dimenionType(ResourceLocation effect) { @@ -73,16 +97,34 @@ public class SkyAddon implements AutoSyncedAddon { return getSelf(); } + + default T dayTime(long dayTime) { + + this.getAddon(ID).dayTime = dayTime; + + return getSelf(); + } + + default T moonPhase(byte moonPhase) { + + this.getAddon(ID).moonPhase = moonPhase; + + return getSelf(); + } } public static class SkyBuilderAddon implements PocketBuilderAddon { private ResourceLocation effect = BuiltinDimensionTypes.OVERWORLD_EFFECTS; + private long dayTime = 12000L; + private byte moonPhase = 0; @Override public void apply(Pocket pocket) { SkyAddon addon = new SkyAddon(); addon.effect = effect; + addon.dayTime = dayTime; + addon.moonPhase = moonPhase; pocket.addAddon(addon); } @@ -93,7 +135,9 @@ public class SkyAddon implements AutoSyncedAddon { @Override public PocketBuilderAddon fromNbt(CompoundTag nbt) { - this.effect = ResourceLocation.tryParse(nbt.getString("world")); + this.effect = ResourceLocation.tryParse(nbt.getString("effect")); + this.dayTime = nbt.getLong("dayTime"); + this.moonPhase = nbt.getByte("moonPhase"); return this; } @@ -102,7 +146,9 @@ public class SkyAddon implements AutoSyncedAddon { public CompoundTag toNbt(CompoundTag nbt) { PocketBuilderAddon.super.toNbt(nbt); - nbt.putString("dimenionType", effect.toString()); + nbt.putString("effect", effect.toString()); + nbt.putLong("dayTime", dayTime); + nbt.putByte("moonPhase", moonPhase); return nbt; } @@ -124,4 +170,34 @@ public class SkyAddon implements AutoSyncedAddon { return this.getAddon(ID).setEfffect(effect); } } + + public static float timeOfDay(long dayTime) { + double d = Mth.frac((double)dayTime / 24000.0 - 0.25); + double e = 0.5 - Math.cos(d * Math.PI) / 2.0; + return (float)(d * 2.0 + e) / 3.0f; + } + + public float getSunAngle() { + float f = this.getTimeOfDay(); + return f * ((float)Math.PI * 2); + } + + public float getTimeOfDay() { + return timeOfDay(getDayTime()); + } + + private long getDayTime() { + return dayTime; + } + + public int getMoonPhase() { + return moonPhase % 8; + } + + public float getStarBrightness() { + float f = this.getTimeOfDay(); + float g = 1.0f - (Mth.cos(f * ((float)Math.PI * 2)) * 2.0f + 0.25f); + g = Mth.clamp(g, 0.0f, 1.0f); + return g * g * 0.5f; + } } diff --git a/common/src/main/resources/data/dimdoors/door/data/gold_door.json b/common/src/main/resources/data/dimdoors/door/data/gold_door.json index 409cd37e..93d88312 100644 --- a/common/src/main/resources/data/dimdoors/door/data/gold_door.json +++ b/common/src/main/resources/data/dimdoors/door/data/gold_door.json @@ -2,7 +2,8 @@ { "data": { "destination": { - "type": "dimdoors:public_pocket" + "type": "dimdoors:template", + "template": "dimdoors:lab/lab_hallway" } }, "condition": { diff --git a/common/src/main/resources/dimdoors.accesswidener b/common/src/main/resources/dimdoors.accesswidener index c426bdb1..148c9df0 100644 --- a/common/src/main/resources/dimdoors.accesswidener +++ b/common/src/main/resources/dimdoors.accesswidener @@ -43,4 +43,11 @@ accessible class net/minecraft/core/particles/SimpleParticleType accessible class net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces$NetherBridgePiece accessible class net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces$PieceWeight -accessible method net/minecraft/world/level/block/DoorBlock playSound (Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Z)V \ No newline at end of file +accessible method net/minecraft/world/level/block/DoorBlock playSound (Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Z)V + +accessible field net/minecraft/client/renderer/LevelRenderer skyBuffer Lcom/mojang/blaze3d/vertex/VertexBuffer; + +accessible field net/minecraft/client/renderer/LevelRenderer SUN_LOCATION Lnet/minecraft/resources/ResourceLocation; +accessible field net/minecraft/client/renderer/LevelRenderer MOON_LOCATION Lnet/minecraft/resources/ResourceLocation; +accessible field net/minecraft/client/renderer/LevelRenderer starBuffer Lcom/mojang/blaze3d/vertex/VertexBuffer; +accessible field net/minecraft/client/renderer/LevelRenderer darkBuffer Lcom/mojang/blaze3d/vertex/VertexBuffer; \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/lab_01.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/lab_01.json new file mode 100644 index 00000000..682cdf03 --- /dev/null +++ b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/lab_01.json @@ -0,0 +1,19 @@ +{ + "type": "dimdoors:schematic", + "id": "lab/lab_01", + "builder": { + "type": "dimdoors:lazy_gen_pocket" + }, + "modifiers": [ + { + "type": "dimdoors:rift_data", + "ids": [1], + "rift_data": "dimdoors:rift_data/pocket_entrance" + }, + { + "type": "dimdoors:template", + "ids": [2], + "templateId": "dimdoors:lab/lab_experimentation" + } + ] +} diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/lab_a0.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/lab_a0.json new file mode 100644 index 00000000..61b55848 --- /dev/null +++ b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/lab_a0.json @@ -0,0 +1,24 @@ +{ + "type": "dimdoors:schematic", + "id": "lab/lab_a0", + "builder": { + "type": "dimdoors:lazy_gen_pocket" + }, + "modifiers": [ + { + "type": "dimdoors:rift_data", + "ids": [1], + "rift_data": "dimdoors:rift_data/pocket_entrance" + }, + { + "type": "dimdoors:rift_data", + "ids": [2, 5], + "rift_data": "dimdoors:rift_data/default_dungeon" + }, + { + "type": "dimdoors:relative", + "point_a": 3, + "point_b": 4 + } + ] +} diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/lab_experimentation.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/lab_experimentation.json new file mode 100644 index 00000000..1e849cad --- /dev/null +++ b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/lab_experimentation.json @@ -0,0 +1,26 @@ +{ + "type": "dimdoors:schematic", + "id": "lab/lab_experimentation", + "builder": { + "type": "dimdoors:lazy_gen_pocket", + "addons": [ + { + "type": "dimdoors:sky", + "effect": "minecraft:overworld", + "dayTime": 6000 + } + ] + }, + "modifiers": [ + { + "type": "dimdoors:rift_data", + "ids": [1], + "rift_data": "dimdoors:rift_data/pocket_entrance" + }, + { + "type": "dimdoors:template", + "ids": [2], + "templateId": "dimdoors:lab/lab_a0" + } + ] +} diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/lab_hallway.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/lab_hallway.json new file mode 100644 index 00000000..99f94184 --- /dev/null +++ b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/lab_hallway.json @@ -0,0 +1,19 @@ +{ + "type": "dimdoors:schematic", + "id": "lab/lab_hallway", + "builder": { + "type": "dimdoors:lazy_gen_pocket" + }, + "modifiers": [ + { + "type": "dimdoors:rift_data", + "ids": [1], + "rift_data": "dimdoors:rift_data/pocket_entrance" + }, + { + "type": "dimdoors:template", + "ids": [2], + "templateId": "dimdoors:lab/reception" + } + ] +} diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/left_lab_hallway.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/left_lab_hallway.json new file mode 100644 index 00000000..0a7c4cfe --- /dev/null +++ b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/left_lab_hallway.json @@ -0,0 +1,19 @@ +{ + "type": "dimdoors:schematic", + "id": "lab/left_lab_hallway", + "builder": { + "type": "dimdoors:lazy_gen_pocket" + }, + "modifiers": [ + { + "type": "dimdoors:rift_data", + "ids": [1], + "rift_data": "dimdoors:rift_data/pocket_entrance" + }, + { + "type": "dimdoors:template", + "ids": [2], + "templateId": "dimdoors:lab/lab_01" + } + ] +} diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/reception.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/reception.json new file mode 100644 index 00000000..6c5d3d4e --- /dev/null +++ b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/reception.json @@ -0,0 +1,24 @@ +{ + "type": "dimdoors:schematic", + "id": "lab/reception", + "builder": { + "type": "dimdoors:lazy_gen_pocket" + }, + "modifiers": [ + { + "type": "dimdoors:rift_data", + "ids": [1], + "rift_data": "dimdoors:rift_data/pocket_entrance" + }, + { + "type": "dimdoors:template", + "ids": [2], + "templateId": "dimdoors:lab/right_lab_hallway" + }, + { + "type": "dimdoors:rift_data", + "ids": [3], + "rift_data": "dimdoors:rift_data/default_dungeon" + } + ] +} diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/right_lab_hallway.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/right_lab_hallway.json new file mode 100644 index 00000000..803cb7da --- /dev/null +++ b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/right_lab_hallway.json @@ -0,0 +1,19 @@ +{ + "type": "dimdoors:schematic", + "id": "lab/right_lab_hallway", + "builder": { + "type": "dimdoors:lazy_gen_pocket" + }, + "modifiers": [ + { + "type": "dimdoors:rift_data", + "ids": [1], + "rift_data": "dimdoors:rift_data/pocket_entrance" + }, + { + "type": "dimdoors:template", + "ids": [2], + "templateId": "dimdoors:lab/left_lab_hallway" + } + ] +} diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/telecommunications.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/telecommunications.json new file mode 100644 index 00000000..ed40a929 --- /dev/null +++ b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/generators/lab/telecommunications.json @@ -0,0 +1,19 @@ +{ + "type": "dimdoors:schematic", + "id": "lab/telecommunications", + "builder": { + "type": "dimdoors:lazy_gen_pocket" + }, + "modifiers": [ + { + "type": "dimdoors:rift_data", + "ids": [1], + "rift_data": "dimdoors:rift_data/pocket_entrance" + }, + { + "type": "dimdoors:template", + "ids": [2], + "templateId": "dimdoors:lab/lab_experimentation" + } + ] +} diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/json/rift_data/limbo.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/json/rift_data/limbo.json new file mode 100644 index 00000000..e69de29b diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/lab_01.schem b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/lab_01.schem new file mode 100644 index 00000000..81a7742c Binary files /dev/null and b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/lab_01.schem differ diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/lab_a0.schem b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/lab_a0.schem new file mode 100644 index 00000000..3c3848f9 Binary files /dev/null and b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/lab_a0.schem differ diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/lab_experimentation.schem b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/lab_experimentation.schem new file mode 100644 index 00000000..f335941b Binary files /dev/null and b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/lab_experimentation.schem differ diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/lab_hallway.schem b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/lab_hallway.schem new file mode 100644 index 00000000..63f6413e Binary files /dev/null and b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/lab_hallway.schem differ diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/left_lab_hallway.schem b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/left_lab_hallway.schem new file mode 100644 index 00000000..d716f33b Binary files /dev/null and b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/left_lab_hallway.schem differ diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/reception.schem b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/reception.schem new file mode 100644 index 00000000..77730562 Binary files /dev/null and b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/reception.schem differ diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/right_lab_hallway.schem b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/right_lab_hallway.schem new file mode 100644 index 00000000..23fd99ab Binary files /dev/null and b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/right_lab_hallway.schem differ diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/telecommunication.schem b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/telecommunication.schem new file mode 100644 index 00000000..1308d38a Binary files /dev/null and b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/telecommunication.schem differ diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/telecommunications.schem b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/telecommunications.schem new file mode 100644 index 00000000..d63008b8 Binary files /dev/null and b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/schematic/lab/telecommunications.schem differ diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/lab_01.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/lab_01.json new file mode 100644 index 00000000..6df444a5 --- /dev/null +++ b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/lab_01.json @@ -0,0 +1,4 @@ +{ + "id": "lab/lab_01", + "type": "dimdoors:id" +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/lab_a0.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/lab_a0.json new file mode 100644 index 00000000..b72e4931 --- /dev/null +++ b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/lab_a0.json @@ -0,0 +1,4 @@ +{ + "id": "lab/lab_a0", + "type": "dimdoors:id" +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/lab_entrance.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/lab_entrance.json new file mode 100644 index 00000000..ba08a8cb --- /dev/null +++ b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/lab_entrance.json @@ -0,0 +1,4 @@ +{ + "id": "lab/lab_entrance", + "type": "dimdoors:id" +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/lab_experimentation.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/lab_experimentation.json new file mode 100644 index 00000000..1f2f2619 --- /dev/null +++ b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/lab_experimentation.json @@ -0,0 +1,4 @@ +{ + "id": "lab/lab_experimentation", + "type": "dimdoors:id" +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/lab_hallway.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/lab_hallway.json new file mode 100644 index 00000000..b3519a18 --- /dev/null +++ b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/lab_hallway.json @@ -0,0 +1,4 @@ +{ + "id": "lab/lab_hallway", + "type": "dimdoors:id" +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/left_lab_hallway.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/left_lab_hallway.json new file mode 100644 index 00000000..2df693e7 --- /dev/null +++ b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/left_lab_hallway.json @@ -0,0 +1,4 @@ +{ + "id": "lab/left_lab_hallway", + "type": "dimdoors:id" +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/reception.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/reception.json new file mode 100644 index 00000000..5d0ab335 --- /dev/null +++ b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/reception.json @@ -0,0 +1,4 @@ +{ + "id": "lab/reception", + "type": "dimdoors:id" +} \ No newline at end of file diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/right_lab_hallway.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/right_lab_hallway.json new file mode 100644 index 00000000..6801bb85 --- /dev/null +++ b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/right_lab_hallway.json @@ -0,0 +1,4 @@ +{ + "id": "lab/right_lab_hallway", + "type": "dimdoors:id" +} diff --git a/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/telecommunications.json b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/telecommunications.json new file mode 100644 index 00000000..686b34f0 --- /dev/null +++ b/common/src/main/resources/resourcepacks/default/data/dimdoors/pockets/virtual/lab/telecommunications.json @@ -0,0 +1,4 @@ +{ + "id": "lab/telecommunications", + "type": "dimdoors:id" +} \ No newline at end of file diff --git a/common/src/main/schematics/org/dimdev/dimdoors/util/schematic/RelativeBlockSample.java b/common/src/main/schematics/org/dimdev/dimdoors/util/schematic/RelativeBlockSample.java index e1019d6d..f1dcf36c 100644 --- a/common/src/main/schematics/org/dimdev/dimdoors/util/schematic/RelativeBlockSample.java +++ b/common/src/main/schematics/org/dimdev/dimdoors/util/schematic/RelativeBlockSample.java @@ -84,7 +84,7 @@ public class RelativeBlockSample implements BlockGetter, LevelWriter { this.entityContainer = HashBiMap.create(); for (CompoundTag entityNbt : schematic.getEntities()) { ListTag doubles = entityNbt.getList("Pos", Tag.TAG_DOUBLE); - this.entityContainer.put(entityNbt, new Vec3(doubles.getDouble(0), doubles.getDouble(1), doubles.getDouble(2))); + this.entityContainer.put(entityNbt, new Vec3(doubles.getDouble(0), doubles.getDouble(1), doubles.getDouble(2)).subtract(Vec3.atLowerCornerOf(schematic.getOffset()))); } } @@ -217,6 +217,15 @@ public class RelativeBlockSample implements BlockGetter, LevelWriter { doubles.set(2, NbtOps.INSTANCE.createDouble(vec.z)); nbt.put("Pos", doubles); + if(nbt.contains("Id")) { + nbt.put("id", nbt.get("Id")); // boogers + nbt.remove("Id"); + } + + if(nbt.contains("UUID")) { + nbt.remove("UUID"); + } + Entity entity = EntityType.create(nbt, world.getLevel()).orElseThrow(NoSuchElementException::new); world.getServer().execute(() -> { world.addFreshEntity(entity); diff --git a/common/src/main/schematics/org/dimdev/dimdoors/util/schematic/SchematicPlacer.java b/common/src/main/schematics/org/dimdev/dimdoors/util/schematic/SchematicPlacer.java index 46159553..fb716673 100644 --- a/common/src/main/schematics/org/dimdev/dimdoors/util/schematic/SchematicPlacer.java +++ b/common/src/main/schematics/org/dimdev/dimdoors/util/schematic/SchematicPlacer.java @@ -3,10 +3,12 @@ package org.dimdev.dimdoors.util.schematic; import dev.architectury.platform.Platform; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.core.BlockPos; +import net.minecraft.core.Vec3i; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.DoubleTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtOps; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -88,17 +90,20 @@ public final class SchematicPlacer { return new int[0][0]; } - private static void placeEntities(int originX, int originY, int originZ, Schematic schematic, WorldGenLevel world) { + private static void placeEntities(BlockPos origin, Schematic schematic, WorldGenLevel world) { List entityNbts = schematic.getEntities(); for (CompoundTag nbt : entityNbts) { ListTag nbtList = Objects.requireNonNull(nbt.getList("Pos", 6), "Entity in schematic \"" + schematic.getMetadata().name() + "\" did not have a Pos nbt list!"); - SchematicPlacer.processPos(nbtList, originX, originY, originZ, nbt); + SchematicPlacer.processPos(nbtList, origin, schematic.getOffset(), nbt); - EntityType entityType = EntityType.by(nbt).orElseThrow(AssertionError::new); + EntityType entityType = EntityType.by(fixEntityId(nbt)).orElseThrow(AssertionError::new); Entity e = entityType.create(world.getLevel()); // TODO: fail with an exception if (e != null) { e.load(nbt); + + e.getSelfAndPassengers().forEach(e1 -> System.out.println("Blep: " + e.getDisplayName().getString() + " " + world.addFreshEntity(e1))); + world.addFreshEntityWithPassengers(e); } } @@ -118,13 +123,13 @@ public final class SchematicPlacer { return nbt; } - private static void processPos(ListTag nbtList, int originX, int originY, int originZ, CompoundTag nbt) { + private static void processPos(ListTag nbtList, BlockPos origin, Vec3i offset, CompoundTag nbt) { double x = nbtList.getDouble(0); double y = nbtList.getDouble(1); double z = nbtList.getDouble(2); nbt.remove("Pos"); - nbt.put("Pos", NbtOps.INSTANCE.createList(Stream.of(DoubleTag.valueOf(x + originX), - DoubleTag.valueOf(y + originY), - DoubleTag.valueOf(z + originZ)))); + nbt.put("Pos", NbtOps.INSTANCE.createList(Stream.of(DoubleTag.valueOf(x + origin.getX() - offset.getX()), + DoubleTag.valueOf(y + origin.getY() - offset.getY()), + DoubleTag.valueOf(z + origin.getZ() - offset.getZ())))); } } diff --git a/fabric/src/main/datagen/org/dimdev/dimdoors/datagen/LootTableProvider.java b/fabric/src/main/datagen/org/dimdev/dimdoors/datagen/LootTableProvider.java index 8bcb889b..43b3e994 100644 --- a/fabric/src/main/datagen/org/dimdev/dimdoors/datagen/LootTableProvider.java +++ b/fabric/src/main/datagen/org/dimdev/dimdoors/datagen/LootTableProvider.java @@ -39,5 +39,72 @@ public class LootTableProvider extends FabricBlockLootTableProvider { this.add(ModBlocks.UNRAVELLED_FABRIC.get(), (blockx) -> BlockLootSubProvider.createSilkTouchDispatchTable(blockx, applyExplosionCondition(blockx, LootItem.lootTableItem(ModItems.FRAYED_FILAMENTS.get()).when(BonusLevelTableCondition.bonusLevelFlatChance(Enchantments.BLOCK_FORTUNE, 0.1F, 0.14285715F, 0.25F, 1.0F)).otherwise(LootItem.lootTableItem(blockx))))); this.dropSelf(ModBlocks.TESSELATING_LOOM.get()); + + this.dropSelf(ModBlocks.DRIFTWOOD_WOOD.get()); + this.dropSelf(ModBlocks.DRIFTWOOD_LOG.get()); + this.dropSelf(ModBlocks.DRIFTWOOD_PLANKS.get()); + this.dropSelf(ModBlocks.DRIFTWOOD_LEAVES.get()); + this.dropSelf(ModBlocks.DRIFTWOOD_SAPLING.get()); + this.dropSelf(ModBlocks.DRIFTWOOD_FENCE.get()); + this.dropSelf(ModBlocks.DRIFTWOOD_GATE.get()); + this.dropSelf(ModBlocks.DRIFTWOOD_BUTTON.get()); + this.dropSelf(ModBlocks.DRIFTWOOD_SLAB.get()); + this.dropSelf(ModBlocks.DRIFTWOOD_STAIRS.get()); + this.dropSelf(ModBlocks.DRIFTWOOD_DOOR.get()); + this.dropSelf(ModBlocks.DRIFTWOOD_TRAPDOOR.get()); + this.dropSelf(ModBlocks.AMALGAM_BLOCK.get()); + this.dropSelf(ModBlocks.AMALGAM_DOOR.get()); + this.dropSelf(ModBlocks.AMALGAM_TRAPDOOR.get()); + this.dropSelf(ModBlocks.RUST.get()); + this.dropSelf(ModBlocks.AMALGAM_SLAB.get()); + this.dropSelf(ModBlocks.AMALGAM_STAIRS.get()); + this.dropSelf(ModBlocks.AMALGAM_ORE.get()); + this.dropSelf(ModBlocks.CLOD_ORE.get()); + this.dropSelf(ModBlocks.CLOD_BLOCK.get()); + this.dropSelf(ModBlocks.GRAVEL_FENCE.get()); + this.dropSelf(ModBlocks.GRAVEL_BUTTON.get()); + this.dropSelf(ModBlocks.GRAVEL_SLAB.get()); + this.dropSelf(ModBlocks.GRAVEL_STAIRS.get()); + this.dropSelf(ModBlocks.GRAVEL_WALL.get()); + this.dropSelf(ModBlocks.DARK_SAND.get()); + this.dropSelf(ModBlocks.DARK_SAND_FENCE.get()); + this.dropSelf(ModBlocks.DARK_SAND_BUTTON.get()); + this.dropSelf(ModBlocks.DARK_SAND_SLAB.get()); + this.dropSelf(ModBlocks.DARK_SAND_STAIRS.get()); + this.dropSelf(ModBlocks.DARK_SAND_WALL.get()); + this.dropSelf(ModBlocks.CLAY_FENCE.get()); + this.dropSelf(ModBlocks.CLAY_GATE.get()); + this.dropSelf(ModBlocks.CLAY_BUTTON.get()); + this.dropSelf(ModBlocks.CLAY_SLAB.get()); + this.dropSelf(ModBlocks.CLAY_STAIRS.get()); + this.dropSelf(ModBlocks.CLAY_WALL.get()); + this.dropSelf(ModBlocks.MUD_FENCE.get()); + this.dropSelf(ModBlocks.MUD_GATE.get()); + this.dropSelf(ModBlocks.MUD_BUTTON.get()); + this.dropSelf(ModBlocks.MUD_SLAB.get()); + this.dropSelf(ModBlocks.MUD_STAIRS.get()); + this.dropSelf(ModBlocks.UNRAVELED_FENCE.get()); + this.dropSelf(ModBlocks.UNRAVELED_GATE.get()); + this.dropSelf(ModBlocks.UNRAVELED_BUTTON.get()); + this.dropSelf(ModBlocks.UNRAVELED_SLAB.get()); + this.dropSelf(ModBlocks.UNRAVELED_STAIRS.get()); + this.dropSelf(ModBlocks.DEEPSLATE_SLAB.get()); + this.dropSelf(ModBlocks.DEEPSLATE_STAIRS.get()); + this.dropSelf(ModBlocks.DEEPSLATE_WALL.get()); + this.dropSelf(ModBlocks.RED_SAND_SLAB.get()); + this.dropSelf(ModBlocks.RED_SAND_STAIRS.get()); + this.dropSelf(ModBlocks.RED_SAND_WALL.get()); + this.dropSelf(ModBlocks.SAND_SLAB.get()); + this.dropSelf(ModBlocks.SAND_STAIRS.get()); + this.dropSelf(ModBlocks.SAND_WALL.get()); + this.dropSelf(ModBlocks.END_STONE_SLAB.get()); + this.dropSelf(ModBlocks.END_STONE_STAIRS.get()); + this.dropSelf(ModBlocks.END_STONE_WALL.get()); + this.dropSelf(ModBlocks.NETHERRACK_FENCE.get()); + this.dropSelf(ModBlocks.NETHERRACK_SLAB.get()); + this.dropSelf(ModBlocks.NETHERRACK_STAIRS.get()); + this.dropSelf(ModBlocks.NETHERRACK_WALL.get()); + this.dropSelf(ModBlocks.UNRAVELED_SPIKE.get()); + this.dropSelf(ModBlocks.GRITTY_STONE.get()); } } diff --git a/gradle.properties b/gradle.properties index 888a682c..3cdab5c3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ minecraft_version=1.20.1 enabled_platforms=fabric,forge archives_base_name=dimdoors -mod_version=5.3.2 +mod_version=5.3.3 maven_group=org.dimdev architectury_version=9.1.12