diff --git a/common/src/main/generated/data/dimdoors/decay_patterns/stone_slab.json b/common/src/main/generated/data/dimdoors/decay_patterns/stone_slab.json index a6f99dc8b..7d556d227 100644 --- a/common/src/main/generated/data/dimdoors/decay_patterns/stone_slab.json +++ b/common/src/main/generated/data/dimdoors/decay_patterns/stone_slab.json @@ -6,7 +6,7 @@ }, "result": { "type": "dimdoors:single_block", - "block": "dimdoors:stone_slab", + "block": "minecraft:stone_slab", "entropy": 1, "world_thread_chance": 0.0 } diff --git a/common/src/main/generated/data/dimdoors/decay_patterns/stone_stairs.json b/common/src/main/generated/data/dimdoors/decay_patterns/stone_stairs.json index 4f6a4ad50..6a1051277 100644 --- a/common/src/main/generated/data/dimdoors/decay_patterns/stone_stairs.json +++ b/common/src/main/generated/data/dimdoors/decay_patterns/stone_stairs.json @@ -6,7 +6,7 @@ }, "result": { "type": "dimdoors:single_block", - "block": "dimdoors:stone_stairs", + "block": "minecraft:stone_stairs", "entropy": 1, "world_thread_chance": 0.0 } diff --git a/common/src/main/generated/data/dimdoors/loot_table/blocks/stone_slab.json b/common/src/main/generated/data/dimdoors/loot_table/blocks/stone_slab.json deleted file mode 100644 index fb1873781..000000000 --- a/common/src/main/generated/data/dimdoors/loot_table/blocks/stone_slab.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "bonus_rolls": 0.0, - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ], - "entries": [ - { - "type": "minecraft:item", - "name": "dimdoors:stone_slab" - } - ], - "rolls": 1.0 - } - ] -} \ No newline at end of file diff --git a/common/src/main/generated/data/dimdoors/loot_table/blocks/stone_stairs.json b/common/src/main/generated/data/dimdoors/loot_table/blocks/stone_stairs.json deleted file mode 100644 index 7702286e5..000000000 --- a/common/src/main/generated/data/dimdoors/loot_table/blocks/stone_stairs.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "bonus_rolls": 0.0, - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ], - "entries": [ - { - "type": "minecraft:item", - "name": "dimdoors:stone_stairs" - } - ], - "rolls": 1.0 - } - ] -} \ No newline at end of file diff --git a/common/src/main/generated/data/dimdoors/tags/block/decays_to/dark_sand_slab.json b/common/src/main/generated/data/dimdoors/tags/block/decays_to/dark_sand_slab.json index 7f4770118..90cc941c4 100644 --- a/common/src/main/generated/data/dimdoors/tags/block/decays_to/dark_sand_slab.json +++ b/common/src/main/generated/data/dimdoors/tags/block/decays_to/dark_sand_slab.json @@ -1,6 +1,6 @@ { "values": [ "dimdoors:clay_slab", - "dimdoors:stone_slab" + "minecraft:stone_slab" ] } \ No newline at end of file diff --git a/common/src/main/generated/data/dimdoors/tags/block/decays_to/dark_sand_stairs.json b/common/src/main/generated/data/dimdoors/tags/block/decays_to/dark_sand_stairs.json index b0272a972..b920bd40f 100644 --- a/common/src/main/generated/data/dimdoors/tags/block/decays_to/dark_sand_stairs.json +++ b/common/src/main/generated/data/dimdoors/tags/block/decays_to/dark_sand_stairs.json @@ -1,6 +1,6 @@ { "values": [ "dimdoors:clay_stairs", - "dimdoors:stone_stairs" + "minecraft:stone_stairs" ] } \ No newline at end of file diff --git a/common/src/main/generated/data/minecraft/tags/block/mineable/pickaxe.json b/common/src/main/generated/data/minecraft/tags/block/mineable/pickaxe.json index 254ef582f..b73d04d42 100644 --- a/common/src/main/generated/data/minecraft/tags/block/mineable/pickaxe.json +++ b/common/src/main/generated/data/minecraft/tags/block/mineable/pickaxe.json @@ -267,8 +267,6 @@ "dimdoors:amalgam_ore", "dimdoors:amalgam_block", "dimdoors:amalgam_trapdoor", - "dimdoors:stone_slab", - "dimdoors:stone_stairs", "dimdoors:stone_wall", "dimdoors:gold_door", "dimdoors:stone_door", diff --git a/common/src/main/generated/data/minecraft/tags/block/slabs.json b/common/src/main/generated/data/minecraft/tags/block/slabs.json index 55b617e7f..a8f9c7307 100644 --- a/common/src/main/generated/data/minecraft/tags/block/slabs.json +++ b/common/src/main/generated/data/minecraft/tags/block/slabs.json @@ -39,7 +39,6 @@ "dimdoors:black_terracotta_slab", "dimdoors:black_glazed_terracotta_slab", "dimdoors:amalgam_slab", - "dimdoors:stone_slab", "dimdoors:gravel_slab", "dimdoors:gravel_slab", "dimdoors:dark_sand_slab", diff --git a/common/src/main/generated/data/minecraft/tags/block/stairs.json b/common/src/main/generated/data/minecraft/tags/block/stairs.json index 9871d0945..67a70d733 100644 --- a/common/src/main/generated/data/minecraft/tags/block/stairs.json +++ b/common/src/main/generated/data/minecraft/tags/block/stairs.json @@ -39,7 +39,6 @@ "dimdoors:black_terracotta_stairs", "dimdoors:black_glazed_terracotta_stairs", "dimdoors:amalgam_stairs", - "dimdoors:stone_stairs", "dimdoors:gravel_stairs", "dimdoors:gravel_stairs", "dimdoors:dark_sand_stairs", diff --git a/common/src/main/java/org/dimdev/dimdoors/block/ModBlocks.java b/common/src/main/java/org/dimdev/dimdoors/block/ModBlocks.java index 3e9167a50..bf63e9fb8 100644 --- a/common/src/main/java/org/dimdev/dimdoors/block/ModBlocks.java +++ b/common/src/main/java/org/dimdev/dimdoors/block/ModBlocks.java @@ -172,8 +172,6 @@ public final class ModBlocks { public static final Block PALE_SAND = registerDecay("pale_sand", new ColoredFallingBlock(new ColorRGBA(0xFFF2E9D1), ofFullCopy(SAND).mapColor(COLOR_LIGHT_GRAY).strength(0.5F).sound(SoundType.SAND))); public static final Block DARK_SAND_LAYER = registerDecay("dark_sand_layer", new CarpetBlock(ofFullCopy(MOSS_CARPET).mapColor(COLOR_BLACK).sound(SoundType.SAND))); public static final Block LINT_LAYER = registerDecay("lint_layer", new CarpetBlock(ofFullCopy(MOSS_CARPET).mapColor(COLOR_LIGHT_GRAY))); - public static final Block STONE_SLAB = registerDecay("stone_slab", new SlabBlock(of(STONE))); - public static final Block STONE_STAIRS = registerDecay("stone_stairs", new ModStairBlock(STONE.defaultBlockState(), of(STONE))); public static final Block STONE_WALL = registerDecay("stone_wall", new WallBlock(of(STONE))); public record DecayGroupSet( diff --git a/common/src/main/java/org/dimdev/dimdoors/block/entity/EntranceRiftBlockEntity.java b/common/src/main/java/org/dimdev/dimdoors/block/entity/EntranceRiftBlockEntity.java index df71686a6..6feee63bb 100644 --- a/common/src/main/java/org/dimdev/dimdoors/block/entity/EntranceRiftBlockEntity.java +++ b/common/src/main/java/org/dimdev/dimdoors/block/entity/EntranceRiftBlockEntity.java @@ -1,8 +1,10 @@ package org.dimdev.dimdoors.block.entity; +import com.mojang.serialization.Codec; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Rotations; +import net.minecraft.nbt.Tag; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; @@ -38,6 +40,8 @@ public class EntranceRiftBlockEntity> extends RiftBlockEntity { private static final EscapeTarget ESCAPE_TARGET = new EscapeTarget(true); + private static final CodecRecord CLOSING_TICKS_BUILDER = new CodecRecord<>("closingTicks", Codec.INT, -1, entranceRiftBlockEntity -> entranceRiftBlockEntity.closingTicks); + protected int closingTicks; protected BlockState doorBlockState; private RiftUtils.PortalPlane plane; @@ -216,6 +220,26 @@ public void setPortalDestination(ServerLevel world) { } } + @Override + public void deserialize(Deserialize nbt) { + super.deserialize(nbt); + closingTicks = nbt.get(CLOSING_TICKS_BUILDER); + } + + @Override + public void serialize(Serialize serialize) { + super.serialize(serialize); + serialize.put(CLOSING_TICKS_BUILDER); + } + + @Override + public void update(Level level, BlockPos pos, BlockState blockState) { + if (closingTicks > 0) { + closingTicks--; + if (closingTicks == 0) { unregister(); } + } + } + @Override public void unregister() { super.unregister(); diff --git a/common/src/main/java/org/dimdev/dimdoors/command/PocketCommand.java b/common/src/main/java/org/dimdev/dimdoors/command/PocketCommand.java index 6a12bec21..ea34f85a1 100644 --- a/common/src/main/java/org/dimdev/dimdoors/command/PocketCommand.java +++ b/common/src/main/java/org/dimdev/dimdoors/command/PocketCommand.java @@ -25,12 +25,14 @@ import net.minecraft.world.level.block.DoorBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.phys.Vec3; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.dimdev.dimdoors.ModRegistryKeys; +import org.dimdev.dimdoors.api.util.math.MathUtil; import org.dimdev.dimdoors.api.util.Location; import org.dimdev.dimdoors.block.RiftVariantProvider; -import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity; +import org.dimdev.dimdoors.block.entity.RiftBlockEntity; import org.dimdev.dimdoors.item.RiftSignatureItem; import org.dimdev.dimdoors.pockets.PocketCreator; import org.dimdev.dimdoors.pockets.PocketGenerationContext; @@ -59,7 +61,6 @@ public class PocketCommand { public static ArgumentBuilder placeOption(String name, ResourceKey> resourceKey) { return literal(name).then( argument("id", ResourceLocationArgument.id()) - .requires(CommandSourceStack::isPlayer) .suggests((ctx, builder) -> getSuggestions(ctx.getSource().registryAccess(), resourceKey, builder)) .executes(context -> placePocket( context.getSource(), @@ -120,23 +121,23 @@ private static int placePocket(CommandSourceStack sour return 0; } - ServerPlayer player = source.getPlayerOrException(); ServerLevel sourceLevel; BlockPos sourcePos; if (selectedSourcePos != null) { - sourceLevel = player.serverLevel(); + sourceLevel = (ServerLevel) source.getLevel(); sourcePos = normalizeSourcePos(sourceLevel, selectedSourcePos); } else if (targetEntity != null) { sourceLevel = (ServerLevel) targetEntity.level(); sourcePos = normalizeSourcePos(sourceLevel, targetEntity.blockPosition()); } else { - sourceLevel = player.serverLevel(); - sourcePos = normalizeSourcePos(sourceLevel, player.blockPosition()); + Entity sourceEntity = source.getEntityOrException(); + sourceLevel = (ServerLevel) sourceEntity.level(); + sourcePos = normalizeSourcePos(sourceLevel, sourceEntity.blockPosition()); } BlockState sourceState = sourceLevel.getBlockState(sourcePos); - if (!canUseSource(player, sourcePos, sourceState)) { + if (!canUseSource(sourcePos, sourceState)) { source.sendFailure(Component.literal("Source position must be a raw rift, a door/trapdoor/portal that can host a rift, or replaceable space.")); return 0; } @@ -185,7 +186,7 @@ private static int placePocket(CommandSourceStack sour TemplateUtils.linkRifts(contextLocation, entrance); if (targetEntity != null - && !((EntranceRiftBlockEntity) contextLocation.getBlockEntity()).teleport(targetEntity)) { // This line does not feel safe but theoretically any block entity errors would happen inside linkRifts + && !((RiftBlockEntity) entrance.getBlockEntity()).receiveEntity(targetEntity, Vec3.ZERO, MathUtil.entityEulerAngle(targetEntity), targetEntity.getDeltaMovement(), null)) { // This line does not feel safe, if linkRifts fails such as because a spot is inaccessable this will throw errors source.sendFailure(Component.literal("Failed to teleport entity through created rift.")); return 0; } @@ -207,9 +208,8 @@ private static BlockPos normalizeSourcePos(ServerLevel level, BlockPos sourcePos return sourcePos; } - private static boolean canUseSource(ServerPlayer player, BlockPos sourcePos, BlockState sourceState) { - return (sourceState.canBeReplaced() || sourceState.getBlock() instanceof RiftVariantProvider) - && player.mayUseItemAt(sourcePos, Direction.UP, ItemStack.EMPTY); + private static boolean canUseSource(BlockPos sourcePos, BlockState sourceState) { + return (sourceState.canBeReplaced() || sourceState.getBlock() instanceof RiftVariantProvider); // mayUseItemAt might be important } public static CompletableFuture getSuggestions(RegistryAccess access, ResourceKey> resourceKey, SuggestionsBuilder builder) { diff --git a/fabric/src/main/datagen/org/dimdev/dimdoors/datagen/AbstractionDecayProvider.java b/fabric/src/main/datagen/org/dimdev/dimdoors/datagen/AbstractionDecayProvider.java index 832ecf12c..32bb16c10 100644 --- a/fabric/src/main/datagen/org/dimdev/dimdoors/datagen/AbstractionDecayProvider.java +++ b/fabric/src/main/datagen/org/dimdev/dimdoors/datagen/AbstractionDecayProvider.java @@ -79,8 +79,8 @@ protected void generatePatterns(HolderLookup.Provider provider, Consumer