Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"result": {
"type": "dimdoors:single_block",
"block": "dimdoors:stone_slab",
"block": "minecraft:stone_slab",
"entropy": 1,
"world_thread_chance": 0.0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"result": {
"type": "dimdoors:single_block",
"block": "dimdoors:stone_stairs",
"block": "minecraft:stone_stairs",
"entropy": 1,
"world_thread_chance": 0.0
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"values": [
"dimdoors:clay_slab",
"dimdoors:stone_slab"
"minecraft:stone_slab"
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"values": [
"dimdoors:clay_stairs",
"dimdoors:stone_stairs"
"minecraft:stone_stairs"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions common/src/main/java/org/dimdev/dimdoors/block/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -38,6 +40,8 @@

public class EntranceRiftBlockEntity<T extends EntranceRiftBlockEntity<T>> extends RiftBlockEntity<T> {
private static final EscapeTarget ESCAPE_TARGET = new EscapeTarget(true);
private static final CodecRecord<EntranceRiftBlockEntity, Integer> CLOSING_TICKS_BUILDER = new CodecRecord<>("closingTicks", Codec.INT, -1, entranceRiftBlockEntity -> entranceRiftBlockEntity.closingTicks);
protected int closingTicks;
protected BlockState doorBlockState;
private RiftUtils.PortalPlane plane;

Expand Down Expand Up @@ -216,6 +220,26 @@ public void setPortalDestination(ServerLevel world) {
}
}

@Override
public void deserialize(Deserialize<Tag> nbt) {
super.deserialize(nbt);
closingTicks = nbt.get(CLOSING_TICKS_BUILDER);
}

@Override
public void serialize(Serialize<Tag, T> 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();
Expand Down
22 changes: 11 additions & 11 deletions common/src/main/java/org/dimdev/dimdoors/command/PocketCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,7 +61,6 @@ public class PocketCommand {
public static <T extends PocketCreator> ArgumentBuilder<CommandSourceStack, ?> placeOption(String name, ResourceKey<Registry<T>> 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(),
Expand Down Expand Up @@ -120,23 +121,23 @@ private static <T extends PocketCreator> 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;
}
Expand Down Expand Up @@ -185,7 +186,7 @@ private static <T extends PocketCreator> 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;
}
Expand All @@ -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 <T extends PocketCreator> CompletableFuture<Suggestions> getSuggestions(RegistryAccess access, ResourceKey<Registry<T>> resourceKey, SuggestionsBuilder builder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ protected void generatePatterns(HolderLookup.Provider provider, Consumer<DecayPa
addConcretePowderPatterns(provider, consumer);

addPattern(Blocks.STONE, ModBlockTags.DECAYS_TO_STONE).accept(consumer, provider);
addPattern(ModBlocks.STONE_SLAB, ModBlockTags.DECAYS_TO_STONE_SLAB).accept(consumer, provider);
addPattern(ModBlocks.STONE_STAIRS, ModBlockTags.DECAYS_TO_STONE_STAIRS).accept(consumer, provider);
addPattern(Blocks.STONE_SLAB, ModBlockTags.DECAYS_TO_STONE_SLAB).accept(consumer, provider);
addPattern(Blocks.STONE_STAIRS, ModBlockTags.DECAYS_TO_STONE_STAIRS).accept(consumer, provider);
addPattern(ModBlocks.STONE_WALL, ModBlockTags.DECAYS_TO_STONE_WALL).accept(consumer, provider);
addPattern(ModBlocks.AMALGAM_BLOCK, ModBlockTags.DECAYS_TO_AMALGAM).accept(consumer, provider);
addPattern(ModBlocks.AMALGAM_ORE, ModBlockTags.DECAYS_TO_AMALGAM_ORE).accept(consumer, provider);
Expand Down Expand Up @@ -437,8 +437,8 @@ private void addPatterns(HolderLookup.Provider provider, Consumer<DecayPatternHo
// addPattern(ModBlocks.SAND_WALL, ModBlockTags.DECAYS_TO_SAND_WALL).accept(consumer, provider);
// addPattern(Blocks.SOUL_SAND, Blocks.SOUL_SOIL).accept(consumer, provider);
// addPattern(Blocks.STONE, ModBlockTags.DECAYS_TO_STONE).accept(consumer, provider);
// addPattern(ModBlocks.STONE_SLAB, ModBlockTags.DECAYS_TO_STONE_SLAB).accept(consumer, provider);
// addPattern(ModBlocks.STONE_STAIRS, ModBlockTags.DECAYS_TO_STONE_STAIRS).accept(consumer, provider);
// addPattern(Blocks.STONE_SLAB, ModBlockTags.DECAYS_TO_STONE_SLAB).accept(consumer, provider);
// addPattern(Blocks.STONE_STAIRS, ModBlockTags.DECAYS_TO_STONE_STAIRS).accept(consumer, provider);
// addPattern(ModBlocks.STONE_WALL, ModBlockTags.DECAYS_TO_STONE_WALL).accept(consumer, provider);
// addPattern(ModBlocks.STONE_DOOR, ModBlockTags.DECAYS_TO_STONE_DOOR).accept(consumer, provider);
// addPattern(ModBlocks.STONE_TRAPDOOR, ModBlockTags.DECAYS_TO_STONE_TRAPDOOR).accept(consumer, provider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public void generate() {
this.dropSelf(ModBlocks.PALE_SAND);
this.dropSelf(ModBlocks.DARK_SAND_LAYER);
this.dropSelf(ModBlocks.LINT_LAYER);
this.dropSelf(ModBlocks.STONE_SLAB);
this.dropSelf(ModBlocks.STONE_STAIRS);
this.dropSelf(Blocks.STONE_SLAB);
this.dropSelf(Blocks.STONE_STAIRS);
this.dropSelf(ModBlocks.STONE_WALL);

this.dropSelf(ModBlocks.GRAVEL_SET);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ protected void configure(HolderGetter.Provider arg) {
add(ModBlockTags.DECAYS_TO_DARK_SAND_BUTTON, ModBlocks.CLAY_SET.button());
add(ModBlockTags.DECAYS_TO_DARK_SAND_SLAB,
ModBlocks.CLAY_SET.slab(),
ModBlocks.STONE_SLAB
Blocks.STONE_SLAB
);
add(ModBlockTags.DECAYS_TO_DARK_SAND_STAIRS,
ModBlocks.CLAY_SET.stairs(),
ModBlocks.STONE_STAIRS
Blocks.STONE_STAIRS
);
add(ModBlockTags.DECAYS_TO_DARK_SAND_WALL,
ModBlocks.CLAY_SET.wall(),
Expand Down Expand Up @@ -1136,8 +1136,8 @@ protected void configure(HolderGetter.Provider arg) {
add(ModBlocks.AMALGAM_ORE, ConventionalBlockTags.ORES, BlockTags.MINEABLE_WITH_PICKAXE);
add(ModBlocks.AMALGAM_BLOCK, BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.BEACON_BASE_BLOCKS);
add(ModBlocks.AMALGAM_TRAPDOOR, BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.TRAPDOORS);
add(ModBlocks.STONE_SLAB, BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.SLABS);
add(ModBlocks.STONE_STAIRS, BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.STAIRS);
add(Blocks.STONE_SLAB, BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.SLABS);
add(Blocks.STONE_STAIRS, BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.STAIRS);
add(ModBlocks.STONE_WALL, BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.WALLS);

add(ModBlocks.GOLD_DOOR, BlockTags.DOORS, BlockTags.MINEABLE_WITH_PICKAXE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ private void generateStoneSet(BlockModelGenerators generator) {
TextureMapping mapping = getTextureMapping(generator, Blocks.STONE);
ResourceLocation fullBlockModel = ModelLocationUtils.getModelLocation(Blocks.STONE);

generateSlab(generator, ModBlocks.STONE_SLAB, mapping, fullBlockModel);
generateStairs(generator, ModBlocks.STONE_STAIRS, mapping);
generateSlab(generator, Blocks.STONE_SLAB, mapping, fullBlockModel);
generateStairs(generator, Blocks.STONE_STAIRS, mapping);
generateWall(generator, ModBlocks.STONE_WALL, mapping);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ public void generateTranslations() {
add(ModBlocks.DARK_SAND_LAYER);
add(ModBlocks.DARK_SAND);
add(ModBlocks.LINT_LAYER);
add(ModBlocks.STONE_SLAB);
add(ModBlocks.STONE_STAIRS);
add(Blocks.STONE_SLAB);
add(Blocks.STONE_STAIRS);
add(ModBlocks.STONE_WALL);

ModBlocks.DecayGroupSet.SETS.forEach(this::addBlockSet);
Expand Down