diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/AbstractCanSurviveBlockBehavior.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/AbstractCanSurviveBlockBehavior.java index d71dbf8ca..03c1baa99 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/AbstractCanSurviveBlockBehavior.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/AbstractCanSurviveBlockBehavior.java @@ -100,7 +100,7 @@ public abstract class AbstractCanSurviveBlockBehavior extends BukkitBlockBehavio } world.playBlockSound(position, previousState.sounds().breakSound()); FastNMS.INSTANCE.method$Level$levelEvent(level, WorldEvents.BLOCK_BREAK_EFFECT, blockPos, stateId); - return CoreReflections.method$Block$defaultBlockState.invoke(MBlocks.AIR); + return MBlocks.AIR$defaultState; } return state; } diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/DoorBlockBehavior.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/DoorBlockBehavior.java index 0e1ef1e42..1f252b397 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/DoorBlockBehavior.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/DoorBlockBehavior.java @@ -7,6 +7,7 @@ import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MBlocks; import net.momirealms.craftengine.bukkit.util.BlockStateUtils; import net.momirealms.craftengine.bukkit.util.DirectionUtils; import net.momirealms.craftengine.bukkit.util.LocationUtils; +import net.momirealms.craftengine.bukkit.world.BukkitWorld; import net.momirealms.craftengine.core.block.BlockBehavior; import net.momirealms.craftengine.core.block.CustomBlock; import net.momirealms.craftengine.core.block.ImmutableBlockState; @@ -17,15 +18,16 @@ import net.momirealms.craftengine.core.block.state.properties.DoorHinge; import net.momirealms.craftengine.core.block.state.properties.DoubleBlockHalf; import net.momirealms.craftengine.core.entity.player.InteractionResult; import net.momirealms.craftengine.core.entity.player.Player; +import net.momirealms.craftengine.core.item.Item; import net.momirealms.craftengine.core.item.context.BlockPlaceContext; import net.momirealms.craftengine.core.item.context.UseOnContext; +import net.momirealms.craftengine.core.plugin.context.ContextHolder; +import net.momirealms.craftengine.core.plugin.context.parameter.DirectContextParameters; import net.momirealms.craftengine.core.util.Direction; import net.momirealms.craftengine.core.util.HorizontalDirection; import net.momirealms.craftengine.core.util.ResourceConfigUtils; import net.momirealms.craftengine.core.util.VersionHelper; -import net.momirealms.craftengine.core.world.BlockPos; -import net.momirealms.craftengine.core.world.Vec3d; -import net.momirealms.craftengine.core.world.World; +import net.momirealms.craftengine.core.world.*; import org.bukkit.Bukkit; import org.bukkit.GameEvent; import org.bukkit.block.Block; @@ -40,7 +42,7 @@ import java.util.Map; import java.util.Optional; import java.util.concurrent.Callable; -public class DoorBlockBehavior extends BukkitBlockBehavior { +public class DoorBlockBehavior extends AbstractCanSurviveBlockBehavior { public static final Factory FACTORY = new Factory(); private final Property halfProperty; private final Property facingProperty; @@ -58,7 +60,7 @@ public class DoorBlockBehavior extends BukkitBlockBehavior { Property openProperty, boolean canOpenWithHand, boolean canOpenByWindCharge) { - super(block); + super(block, 0); this.halfProperty = halfProperty; this.facingProperty = facingProperty; this.hingeProperty = hingeProperty; @@ -73,9 +75,19 @@ public class DoorBlockBehavior extends BukkitBlockBehavior { } @Override - public Object updateShape(Object thisBlock, Object[] args, Callable superMethod) { + public Object updateShape(Object thisBlock, Object[] args, Callable superMethod) throws Exception { + Object level; + Object blockPos; Object blockState = args[0]; - ImmutableBlockState immutableBlockState = BukkitBlockManager.instance().getImmutableBlockState(BlockStateUtils.blockStateToId(blockState)); + if (VersionHelper.isOrAbove1_21_2()) { + level = args[1]; + blockPos = args[3]; + } else { + level = args[3]; + blockPos = args[4]; + } + int stateId = BlockStateUtils.blockStateToId(blockState); + ImmutableBlockState immutableBlockState = BukkitBlockManager.instance().getImmutableBlockState(stateId); if (immutableBlockState == null || immutableBlockState.isEmpty()) return blockState; DoubleBlockHalf half = immutableBlockState.get(this.halfProperty); Object direction = VersionHelper.isOrAbove1_21_2() ? args[4] : args[0]; @@ -89,13 +101,25 @@ public class DoorBlockBehavior extends BukkitBlockBehavior { return MBlocks.AIR$defaultState; } if (neighborState.get(anotherDoorBehavior.get().halfProperty) != half) { - return neighborState.with(anotherDoorBehavior.get().halfProperty, half); + return neighborState.with(anotherDoorBehavior.get().halfProperty, half).customBlockState().handle(); } return MBlocks.AIR$defaultState; } else { - return half == DoubleBlockHalf.LOWER && - direction == CoreReflections.instance$Direction$DOWN && - !FastNMS.INSTANCE.method$BlockStateBase$canSurvive(blockState, VersionHelper.isOrAbove1_21_2() ? args[1] : args[3], VersionHelper.isOrAbove1_21_2() ? args[3] : args[2]) ? MBlocks.AIR$defaultState : blockState; + if (half == DoubleBlockHalf.LOWER && direction == CoreReflections.instance$Direction$DOWN + && !canSurvive(thisBlock, blockState, level, blockPos)) { + BlockPos pos = LocationUtils.fromBlockPos(blockPos); + net.momirealms.craftengine.core.world.World world = new BukkitWorld(FastNMS.INSTANCE.method$Level$getCraftWorld(level)); + WorldPosition position = new WorldPosition(world, Vec3d.atCenterOf(pos)); + ContextHolder.Builder builder = ContextHolder.builder() + .withParameter(DirectContextParameters.POSITION, position); + for (Item item : immutableBlockState.getDrops(builder, world, null)) { + world.dropItemNaturally(position, item); + } + world.playBlockSound(position, immutableBlockState.sounds().breakSound()); + FastNMS.INSTANCE.method$Level$levelEvent(level, WorldEvents.BLOCK_BREAK_EFFECT, blockPos, stateId); + return MBlocks.AIR$defaultState; + } + return blockState; } } @@ -111,6 +135,12 @@ public class DoorBlockBehavior extends BukkitBlockBehavior { } } + @Override + public void setPlacedBy(BlockPlaceContext context, ImmutableBlockState state) { + BlockPos pos = context.getClickedPos(); + context.getLevel().setBlockAt(pos.x(), pos.y() + 1, pos.z(), state.with(this.halfProperty, DoubleBlockHalf.UPPER).customBlockState(), 3); + } + @Override public ImmutableBlockState updateStateForPlacement(BlockPlaceContext context, ImmutableBlockState state) { World world = context.getLevel(); @@ -191,11 +221,11 @@ public class DoorBlockBehavior extends BukkitBlockBehavior { @Override public InteractionResult useOnBlock(UseOnContext context, ImmutableBlockState state) { - if (!this.canOpenWithHand) { + if (!this.canOpenWithHand || context.getPlayer().isSecondaryUseActive()) { return InteractionResult.PASS; } setOpen(context.getPlayer(), context.getLevel().serverWorld(), state, context.getClickedPos(), !state.get(this.openProperty)); - return InteractionResult.SUCCESS; + return InteractionResult.SUCCESS_AND_CANCEL; } @Override @@ -235,6 +265,22 @@ public class DoorBlockBehavior extends BukkitBlockBehavior { } } + @Override + public boolean canSurvive(Object thisBlock, Object state, Object world, Object blockPos) throws Exception { + ImmutableBlockState immutableBlockState = BukkitBlockManager.instance().getImmutableBlockState(BlockStateUtils.blockStateToId(state)); + if (immutableBlockState == null || immutableBlockState.isEmpty()) return false; + if (immutableBlockState.get(this.halfProperty) == DoubleBlockHalf.UPPER) return true; + int x = FastNMS.INSTANCE.field$Vec3i$x(blockPos); + int y = FastNMS.INSTANCE.field$Vec3i$y(blockPos) - 1; + int z = FastNMS.INSTANCE.field$Vec3i$z(blockPos); + Object targetPos = FastNMS.INSTANCE.constructor$BlockPos(x, y, z); + Object blockState = FastNMS.INSTANCE.method$BlockGetter$getBlockState(world, targetPos); + return (boolean) CoreReflections.method$BlockStateBase$isFaceSturdy.invoke( + blockState, world, targetPos, CoreReflections.instance$Direction$UP, + CoreReflections.instance$SupportType$FULL + ); + } + @SuppressWarnings("unchecked") public static class Factory implements BlockBehaviorFactory { @Override diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/StackableBlockBehavior.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/StackableBlockBehavior.java index e4198b25f..a75504d60 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/StackableBlockBehavior.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/StackableBlockBehavior.java @@ -8,6 +8,7 @@ import net.momirealms.craftengine.core.block.ImmutableBlockState; import net.momirealms.craftengine.core.block.UpdateOption; import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory; import net.momirealms.craftengine.core.block.properties.IntegerProperty; +import net.momirealms.craftengine.core.entity.player.InteractionHand; import net.momirealms.craftengine.core.entity.player.InteractionResult; import net.momirealms.craftengine.core.entity.player.Player; import net.momirealms.craftengine.core.item.Item; @@ -50,22 +51,36 @@ public class StackableBlockBehavior extends BukkitBlockBehavior { if (item == null) { return InteractionResult.PASS; } - if (this.items.contains(item.id()) && state.get(this.amountProperty) < this.amountProperty.max) { - ImmutableBlockState nextStage = state.cycle(this.amountProperty); - World world = context.getLevel(); - BlockPos pos = context.getClickedPos(); - Location location = new Location((org.bukkit.World) world.platformWorld(), pos.x(), pos.y(), pos.z()); - FastNMS.INSTANCE.method$LevelWriter$setBlock(world.serverWorld(), LocationUtils.toBlockPos(pos), nextStage.customBlockState().handle(), UpdateOption.UPDATE_NONE.flags()); - if (stackSound != null) { - location.getWorld().playSound(location, stackSound.id().toString(), SoundCategory.BLOCKS, stackSound.volume(), stackSound.pitch()); - } - FastNMS.INSTANCE.method$ItemStack$consume(item.getLiteralObject(), 1, player.serverPlayer()); - player.swingHand(context.getHand()); + if (!this.items.contains(item.id())) { + return InteractionResult.PASS; + } + BlockPos pos = context.getClickedPos(); + World world = context.getLevel(); + if (state.get(this.amountProperty) < this.amountProperty.max) { + updateStackableBlock(state, pos, world, item, player, context.getHand()); + return InteractionResult.SUCCESS_AND_CANCEL; + } + BlockPos actualPos = pos.relative(context.getClickedFace()); + ImmutableBlockState actualState = world.getBlockAt(actualPos).customBlockState(); + boolean isValid = actualState != null && !actualState.isEmpty() && actualState.contains(this.amountProperty); + if (isValid && actualState.get(this.amountProperty) < this.amountProperty.max) { + updateStackableBlock(actualState, actualPos, world, item, player, context.getHand()); return InteractionResult.SUCCESS_AND_CANCEL; } return InteractionResult.PASS; } + private void updateStackableBlock(ImmutableBlockState state, BlockPos pos, World world, Item item, Player player, InteractionHand hand) { + ImmutableBlockState nextStage = state.cycle(this.amountProperty); + Location location = new Location((org.bukkit.World) world.platformWorld(), pos.x(), pos.y(), pos.z()); + FastNMS.INSTANCE.method$LevelWriter$setBlock(world.serverWorld(), LocationUtils.toBlockPos(pos), nextStage.customBlockState().handle(), UpdateOption.UPDATE_NONE.flags()); + if (stackSound != null) { + location.getWorld().playSound(location, stackSound.id().toString(), SoundCategory.BLOCKS, stackSound.volume(), stackSound.pitch()); + } + FastNMS.INSTANCE.method$ItemStack$consume(item.getLiteralObject(), 1, player.serverPlayer()); + player.swingHand(hand); + } + public static class Factory implements BlockBehaviorFactory { @Override diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/item/behavior/BlockItemBehavior.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/item/behavior/BlockItemBehavior.java index 9a7ae14bc..213c4ca49 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/item/behavior/BlockItemBehavior.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/item/behavior/BlockItemBehavior.java @@ -159,6 +159,8 @@ public class BlockItemBehavior extends ItemBehavior { item.load(); } + block.setPlacedBy(context, blockStateToPlace); + player.swingHand(context.getHand()); context.getLevel().playBlockSound(position, blockStateToPlace.sounds().placeSound()); world.sendGameEvent(bukkitPlayer, GameEvent.BLOCK_PLACE, new Vector(pos.x(), pos.y(), pos.z())); diff --git a/common-files/src/main/resources/additional-real-blocks.yml b/common-files/src/main/resources/additional-real-blocks.yml index 9b383231d..d576f66f1 100644 --- a/common-files/src/main/resources/additional-real-blocks.yml +++ b/common-files/src/main/resources/additional-real-blocks.yml @@ -43,4 +43,5 @@ minecraft:oxidized_copper_trapdoor: 32 minecraft:waxed_copper_trapdoor: 32 minecraft:waxed_exposed_copper_trapdoor: 32 minecraft:waxed_weathered_copper_trapdoor: 32 -minecraft:waxed_oxidized_copper_trapdoor: 32 \ No newline at end of file +minecraft:waxed_oxidized_copper_trapdoor: 32 +minecraft:oak_door: 64 \ No newline at end of file diff --git a/common-files/src/main/resources/mappings.yml b/common-files/src/main/resources/mappings.yml index 378281eb0..5303d07d0 100644 --- a/common-files/src/main/resources/mappings.yml +++ b/common-files/src/main/resources/mappings.yml @@ -3108,4 +3108,38 @@ minecraft:warped_trapdoor[facing=west,half=bottom,open=false,powered=true,waterl # minecraft:chorus_plant[down=true,east=true,north=false,south=true,up=true,west=true]: minecraft:chorus_plant[down=true,east=true,north=true,south=true,up=true,west=true] # minecraft:chorus_plant[down=false,east=false,north=true,south=true,up=true,west=true]: minecraft:chorus_plant[down=true,east=true,north=true,south=true,up=true,west=true] # minecraft:chorus_plant[down=true,east=false,north=true,south=true,up=true,west=true]: minecraft:chorus_plant[down=true,east=true,north=true,south=true,up=true,west=true] -# minecraft:chorus_plant[down=false,east=true,north=true,south=true,up=true,west=true]: minecraft:chorus_plant[down=true,east=true,north=true,south=true,up=true,west=true] \ No newline at end of file +# minecraft:chorus_plant[down=false,east=true,north=true,south=true,up=true,west=true]: minecraft:chorus_plant[down=true,east=true,north=true,south=true,up=true,west=true] + +# oak door +minecraft:oak_door[facing=east,half=lower,hinge=left,open=false,powered=true]: minecraft:oak_door[facing=east,half=lower,hinge=left,open=false,powered=false] +minecraft:oak_door[facing=east,half=lower,hinge=right,open=false,powered=true]: minecraft:oak_door[facing=east,half=lower,hinge=right,open=false,powered=false] +minecraft:oak_door[facing=east,half=upper,hinge=left,open=false,powered=true]: minecraft:oak_door[facing=east,half=upper,hinge=left,open=false,powered=false] +minecraft:oak_door[facing=east,half=upper,hinge=right,open=false,powered=true]: minecraft:oak_door[facing=east,half=upper,hinge=right,open=false,powered=false] +minecraft:oak_door[facing=north,half=lower,hinge=left,open=false,powered=true]: minecraft:oak_door[facing=north,half=lower,hinge=left,open=false,powered=false] +minecraft:oak_door[facing=north,half=lower,hinge=right,open=false,powered=true]: minecraft:oak_door[facing=north,half=lower,hinge=right,open=false,powered=false] +minecraft:oak_door[facing=north,half=upper,hinge=left,open=false,powered=true]: minecraft:oak_door[facing=north,half=upper,hinge=left,open=false,powered=false] +minecraft:oak_door[facing=north,half=upper,hinge=right,open=false,powered=true]: minecraft:oak_door[facing=north,half=upper,hinge=right,open=false,powered=false] +minecraft:oak_door[facing=south,half=lower,hinge=left,open=false,powered=true]: minecraft:oak_door[facing=south,half=lower,hinge=left,open=false,powered=false] +minecraft:oak_door[facing=south,half=lower,hinge=right,open=false,powered=true]: minecraft:oak_door[facing=south,half=lower,hinge=right,open=false,powered=false] +minecraft:oak_door[facing=south,half=upper,hinge=left,open=false,powered=true]: minecraft:oak_door[facing=south,half=upper,hinge=left,open=false,powered=false] +minecraft:oak_door[facing=south,half=upper,hinge=right,open=false,powered=true]: minecraft:oak_door[facing=south,half=upper,hinge=right,open=false,powered=false] +minecraft:oak_door[facing=west,half=lower,hinge=left,open=false,powered=true]: minecraft:oak_door[facing=west,half=lower,hinge=left,open=false,powered=false] +minecraft:oak_door[facing=west,half=lower,hinge=right,open=false,powered=true]: minecraft:oak_door[facing=west,half=lower,hinge=right,open=false,powered=false] +minecraft:oak_door[facing=west,half=upper,hinge=left,open=false,powered=true]: minecraft:oak_door[facing=west,half=upper,hinge=left,open=false,powered=false] +minecraft:oak_door[facing=west,half=upper,hinge=right,open=false,powered=true]: minecraft:oak_door[facing=west,half=upper,hinge=right,open=false,powered=false] +minecraft:oak_door[facing=east,half=lower,hinge=left,open=true,powered=true]: minecraft:oak_door[facing=east,half=lower,hinge=left,open=true,powered=false] +minecraft:oak_door[facing=east,half=lower,hinge=right,open=true,powered=true]: minecraft:oak_door[facing=east,half=lower,hinge=right,open=true,powered=false] +minecraft:oak_door[facing=east,half=upper,hinge=left,open=true,powered=true]: minecraft:oak_door[facing=east,half=upper,hinge=left,open=true,powered=false] +minecraft:oak_door[facing=east,half=upper,hinge=right,open=true,powered=true]: minecraft:oak_door[facing=east,half=upper,hinge=right,open=true,powered=false] +minecraft:oak_door[facing=north,half=lower,hinge=left,open=true,powered=true]: minecraft:oak_door[facing=north,half=lower,hinge=left,open=true,powered=false] +minecraft:oak_door[facing=north,half=lower,hinge=right,open=true,powered=true]: minecraft:oak_door[facing=north,half=lower,hinge=right,open=true,powered=false] +minecraft:oak_door[facing=north,half=upper,hinge=left,open=true,powered=true]: minecraft:oak_door[facing=north,half=upper,hinge=left,open=true,powered=false] +minecraft:oak_door[facing=north,half=upper,hinge=right,open=true,powered=true]: minecraft:oak_door[facing=north,half=upper,hinge=right,open=true,powered=false] +minecraft:oak_door[facing=south,half=lower,hinge=left,open=true,powered=true]: minecraft:oak_door[facing=south,half=lower,hinge=left,open=true,powered=false] +minecraft:oak_door[facing=south,half=lower,hinge=right,open=true,powered=true]: minecraft:oak_door[facing=south,half=lower,hinge=right,open=true,powered=false] +minecraft:oak_door[facing=south,half=upper,hinge=left,open=true,powered=true]: minecraft:oak_door[facing=south,half=upper,hinge=left,open=true,powered=false] +minecraft:oak_door[facing=south,half=upper,hinge=right,open=true,powered=true]: minecraft:oak_door[facing=south,half=upper,hinge=right,open=true,powered=false] +minecraft:oak_door[facing=west,half=lower,hinge=left,open=true,powered=true]: minecraft:oak_door[facing=west,half=lower,hinge=left,open=true,powered=false] +minecraft:oak_door[facing=west,half=lower,hinge=right,open=true,powered=true]: minecraft:oak_door[facing=west,half=lower,hinge=right,open=true,powered=false] +minecraft:oak_door[facing=west,half=upper,hinge=left,open=true,powered=true]: minecraft:oak_door[facing=west,half=upper,hinge=left,open=true,powered=false] +minecraft:oak_door[facing=west,half=upper,hinge=right,open=true,powered=true]: minecraft:oak_door[facing=west,half=upper,hinge=right,open=true,powered=false] \ No newline at end of file diff --git a/common-files/src/main/resources/resources/default/configuration/categories.yml b/common-files/src/main/resources/resources/default/configuration/categories.yml index 128180d77..d059a6fc3 100644 --- a/common-files/src/main/resources/resources/default/configuration/categories.yml +++ b/common-files/src/main/resources/resources/default/configuration/categories.yml @@ -23,6 +23,7 @@ categories: - default:stripped_palm_wood - default:palm_planks - default:palm_trapdoor + - default:palm_door default:topaz: name: <#FF8C00> hidden: true diff --git a/common-files/src/main/resources/resources/default/configuration/palm_tree.yml b/common-files/src/main/resources/resources/default/configuration/palm_tree.yml index c3d56d240..5f4d0b5cf 100644 --- a/common-files/src/main/resources/resources/default/configuration/palm_tree.yml +++ b/common-files/src/main/resources/resources/default/configuration/palm_tree.yml @@ -334,6 +334,94 @@ items: parent: minecraft:block/template_orientable_trapdoor_top textures: texture: minecraft:block/custom/palm_trapdoor + default:palm_door: + material: nether_brick + custom-model-data: 1007 + data: + item-name: + model: + template: default:model/simplified_generated + arguments: + path: minecraft:item/custom/palm_door + behavior: + type: block_item + block: + behavior: + type: door_block + can-open-with-hand: true + can-open-by-wind-charge: true + loot: + template: default:loot_table/self + settings: + template: + - default:sound/wood + overrides: + push-reaction: DESTROY + map-color: 2 + instrument: bass + hardness: 3.0 + resistance: 3.0 + burnable: true + tags: + - minecraft:doors + - minecraft:mineable/axe + - minecraft:mob_interactable_doors + states: + template: default:block_state/door + arguments: + base_block: oak_door + internal_id: + type: self_increase_int + from: 0 + to: 63 + model_top_left_path: minecraft:block/custom/palm_door_top_left + model_top_left_generation: + parent: minecraft:block/door_top_left + textures: + bottom: minecraft:block/custom/palm_door_bottom + top: minecraft:block/custom/palm_door_top + model_top_right_path: minecraft:block/custom/palm_door_top_right + model_top_right_generation: + parent: minecraft:block/door_top_right + textures: + bottom: minecraft:block/custom/palm_door_bottom + top: minecraft:block/custom/palm_door_top + model_top_left_open_path: minecraft:block/custom/palm_door_top_left_open + model_top_left_open_generation: + parent: minecraft:block/door_top_left_open + textures: + bottom: minecraft:block/custom/palm_door_bottom + top: minecraft:block/custom/palm_door_top + model_top_right_open_path: minecraft:block/custom/palm_door_top_right_open + model_top_right_open_generation: + parent: minecraft:block/door_top_right_open + textures: + bottom: minecraft:block/custom/palm_door_bottom + top: minecraft:block/custom/palm_door_top + model_bottom_left_path: minecraft:block/custom/palm_door_bottom_left + model_bottom_left_generation: + parent: minecraft:block/door_bottom_left + textures: + bottom: minecraft:block/custom/palm_door_bottom + top: minecraft:block/custom/palm_door_top + model_bottom_right_path: minecraft:block/custom/palm_door_bottom_right + model_bottom_right_generation: + parent: minecraft:block/door_bottom_right + textures: + bottom: minecraft:block/custom/palm_door_bottom + top: minecraft:block/custom/palm_door_top + model_bottom_left_open_path: minecraft:block/custom/palm_door_bottom_left_open + model_bottom_left_open_generation: + parent: minecraft:block/door_bottom_left_open + textures: + bottom: minecraft:block/custom/palm_door_bottom + top: minecraft:block/custom/palm_door_top + model_bottom_right_open_path: minecraft:block/custom/palm_door_bottom_right_open + model_bottom_right_open_generation: + parent: minecraft:block/door_bottom_right_open + textures: + bottom: minecraft:block/custom/palm_door_bottom + top: minecraft:block/custom/palm_door_top recipes: default:palm_planks: template: default:recipe/planks diff --git a/common-files/src/main/resources/resources/default/configuration/templates.yml b/common-files/src/main/resources/resources/default/configuration/templates.yml index f8381343f..898d068d0 100644 --- a/common-files/src/main/resources/resources/default/configuration/templates.yml +++ b/common-files/src/main/resources/resources/default/configuration/templates.yml @@ -1462,6 +1462,375 @@ templates#block_states: resistance: 1200.0 burnable: false fluid-state: water + # door block + default:block_state/door: + properties: + facing: + type: horizontal_direction + half: + type: double_block_half + hinge: + type: hinge + open: + type: boolean + default: false + powered: + type: boolean + default: false + appearances: + facing=east,half=lower,hinge=left,open=false: + state: ${base_block}[facing=east,half=lower,hinge=left,open=false,powered=true] + model: + path: ${model_bottom_left_path} + generation: ${model_bottom_left_generation} + facing=east,half=lower,hinge=left,open=true: + state: ${base_block}[facing=east,half=lower,hinge=left,open=true,powered=true] + model: + path: ${model_bottom_left_open_path} + y: 90 + generation: ${model_bottom_left_open_generation} + facing=east,half=lower,hinge=right,open=false: + state: ${base_block}[facing=east,half=lower,hinge=right,open=false,powered=true] + model: + path: ${model_bottom_right_path} + generation: ${model_bottom_right_generation} + facing=east,half=lower,hinge=right,open=true: + state: ${base_block}[facing=east,half=lower,hinge=right,open=true,powered=true] + model: + path: ${model_bottom_right_open_path} + y: 270 + generation: ${model_bottom_right_open_generation} + facing=east,half=upper,hinge=left,open=false: + state: ${base_block}[facing=east,half=upper,hinge=left,open=false,powered=true] + model: + path: ${model_top_left_path} + generation: ${model_top_left_generation} + facing=east,half=upper,hinge=left,open=true: + state: ${base_block}[facing=east,half=upper,hinge=left,open=true,powered=true] + model: + path: ${model_top_left_open_path} + y: 90 + generation: ${model_top_left_open_generation} + facing=east,half=upper,hinge=right,open=false: + state: ${base_block}[facing=east,half=upper,hinge=right,open=false,powered=true] + model: + path: ${model_top_right_path} + generation: ${model_top_right_generation} + facing=east,half=upper,hinge=right,open=true: + state: ${base_block}[facing=east,half=upper,hinge=right,open=true,powered=true] + model: + path: ${model_top_right_open_path} + y: 270 + generation: ${model_top_right_open_generation} + facing=north,half=lower,hinge=left,open=false: + state: ${base_block}[facing=north,half=lower,hinge=left,open=false,powered=true] + model: + path: ${model_bottom_left_path} + y: 270 + facing=north,half=lower,hinge=left,open=true: + state: ${base_block}[facing=north,half=lower,hinge=left,open=true,powered=true] + model: + path: ${model_bottom_left_open_path} + facing=north,half=lower,hinge=right,open=false: + state: ${base_block}[facing=north,half=lower,hinge=right,open=false,powered=true] + model: + path: ${model_bottom_right_path} + y: 270 + facing=north,half=lower,hinge=right,open=true: + state: ${base_block}[facing=north,half=lower,hinge=right,open=true,powered=true] + model: + path: ${model_bottom_right_open_path} + y: 180 + facing=north,half=upper,hinge=left,open=false: + state: ${base_block}[facing=north,half=upper,hinge=left,open=false,powered=true] + model: + path: ${model_top_left_path} + y: 270 + facing=north,half=upper,hinge=left,open=true: + state: ${base_block}[facing=north,half=upper,hinge=left,open=true,powered=true] + model: + path: ${model_top_left_open_path} + facing=north,half=upper,hinge=right,open=false: + state: ${base_block}[facing=north,half=upper,hinge=right,open=false,powered=true] + model: + path: ${model_top_right_path} + y: 270 + facing=north,half=upper,hinge=right,open=true: + state: ${base_block}[facing=north,half=upper,hinge=right,open=true,powered=true] + model: + path: ${model_top_right_open_path} + y: 180 + facing=south,half=lower,hinge=left,open=false: + state: ${base_block}[facing=south,half=lower,hinge=left,open=false,powered=true] + model: + path: ${model_bottom_left_path} + y: 90 + facing=south,half=lower,hinge=left,open=true: + state: ${base_block}[facing=south,half=lower,hinge=left,open=true,powered=true] + model: + path: ${model_bottom_left_open_path} + y: 180 + facing=south,half=lower,hinge=right,open=false: + state: ${base_block}[facing=south,half=lower,hinge=right,open=false,powered=true] + model: + path: ${model_bottom_right_path} + y: 90 + facing=south,half=lower,hinge=right,open=true: + state: ${base_block}[facing=south,half=lower,hinge=right,open=true,powered=true] + model: + path: ${model_bottom_right_open_path} + facing=south,half=upper,hinge=left,open=false: + state: ${base_block}[facing=south,half=upper,hinge=left,open=false,powered=true] + model: + path: ${model_top_left_path} + y: 90 + facing=south,half=upper,hinge=left,open=true: + state: ${base_block}[facing=south,half=upper,hinge=left,open=true,powered=true] + model: + path: ${model_top_left_open_path} + y: 180 + facing=south,half=upper,hinge=right,open=false: + state: ${base_block}[facing=south,half=upper,hinge=right,open=false,powered=true] + model: + path: ${model_top_right_path} + y: 90 + facing=south,half=upper,hinge=right,open=true: + state: ${base_block}[facing=south,half=upper,hinge=right,open=true,powered=true] + model: + path: ${model_top_right_open_path} + facing=west,half=lower,hinge=left,open=false: + state: ${base_block}[facing=west,half=lower,hinge=left,open=false,powered=true] + model: + path: ${model_bottom_left_path} + y: 180 + facing=west,half=lower,hinge=left,open=true: + state: ${base_block}[facing=west,half=lower,hinge=left,open=true,powered=true] + model: + path: ${model_bottom_left_open_path} + y: 270 + facing=west,half=lower,hinge=right,open=false: + state: ${base_block}[facing=west,half=lower,hinge=right,open=false,powered=true] + model: + path: ${model_bottom_right_path} + y: 180 + facing=west,half=lower,hinge=right,open=true: + state: ${base_block}[facing=west,half=lower,hinge=right,open=true,powered=true] + model: + path: ${model_bottom_right_open_path} + y: 90 + facing=west,half=upper,hinge=left,open=false: + state: ${base_block}[facing=west,half=upper,hinge=left,open=false,powered=true] + model: + path: ${model_top_left_path} + y: 180 + facing=west,half=upper,hinge=left,open=true: + state: ${base_block}[facing=west,half=upper,hinge=left,open=true,powered=true] + model: + path: ${model_top_left_open_path} + y: 270 + facing=west,half=upper,hinge=right,open=false: + state: ${base_block}[facing=west,half=upper,hinge=right,open=false,powered=true] + model: + path: ${model_top_right_path} + y: 180 + facing=west,half=upper,hinge=right,open=true: + state: ${base_block}[facing=west,half=upper,hinge=right,open=true,powered=true] + model: + path: ${model_top_right_open_path} + y: 90 + variants: + facing=east,half=lower,hinge=left,open=false,powered=true: + appearance: facing=east,half=lower,hinge=left,open=false + id: ${internal_id} + facing=east,half=lower,hinge=left,open=false,powered=false: + appearance: facing=east,half=lower,hinge=left,open=false + id: ${internal_id} + facing=east,half=lower,hinge=right,open=false,powered=true: + appearance: facing=east,half=lower,hinge=right,open=false + id: ${internal_id} + facing=east,half=lower,hinge=right,open=false,powered=false: + appearance: facing=east,half=lower,hinge=right,open=false + id: ${internal_id} + facing=east,half=upper,hinge=left,open=false,powered=true: + appearance: facing=east,half=upper,hinge=left,open=false + id: ${internal_id} + facing=east,half=upper,hinge=left,open=false,powered=false: + appearance: facing=east,half=upper,hinge=left,open=false + id: ${internal_id} + facing=east,half=upper,hinge=right,open=false,powered=true: + appearance: facing=east,half=upper,hinge=right,open=false + id: ${internal_id} + facing=east,half=upper,hinge=right,open=false,powered=false: + appearance: facing=east,half=upper,hinge=right,open=false + id: ${internal_id} + facing=north,half=lower,hinge=left,open=false,powered=true: + appearance: facing=north,half=lower,hinge=left,open=false + id: ${internal_id} + facing=north,half=lower,hinge=left,open=false,powered=false: + appearance: facing=north,half=lower,hinge=left,open=false + id: ${internal_id} + facing=north,half=lower,hinge=right,open=false,powered=true: + appearance: facing=north,half=lower,hinge=right,open=false + id: ${internal_id} + facing=north,half=lower,hinge=right,open=false,powered=false: + appearance: facing=north,half=lower,hinge=right,open=false + id: ${internal_id} + facing=north,half=upper,hinge=left,open=false,powered=true: + appearance: facing=north,half=upper,hinge=left,open=false + id: ${internal_id} + facing=north,half=upper,hinge=left,open=false,powered=false: + appearance: facing=north,half=upper,hinge=left,open=false + id: ${internal_id} + facing=north,half=upper,hinge=right,open=false,powered=true: + appearance: facing=north,half=upper,hinge=right,open=false + id: ${internal_id} + facing=north,half=upper,hinge=right,open=false,powered=false: + appearance: facing=north,half=upper,hinge=right,open=false + id: ${internal_id} + facing=south,half=lower,hinge=left,open=false,powered=true: + appearance: facing=south,half=lower,hinge=left,open=false + id: ${internal_id} + facing=south,half=lower,hinge=left,open=false,powered=false: + appearance: facing=south,half=lower,hinge=left,open=false + id: ${internal_id} + facing=south,half=lower,hinge=right,open=false,powered=true: + appearance: facing=south,half=lower,hinge=right,open=false + id: ${internal_id} + facing=south,half=lower,hinge=right,open=false,powered=false: + appearance: facing=south,half=lower,hinge=right,open=false + id: ${internal_id} + facing=south,half=upper,hinge=left,open=false,powered=true: + appearance: facing=south,half=upper,hinge=left,open=false + id: ${internal_id} + facing=south,half=upper,hinge=left,open=false,powered=false: + appearance: facing=south,half=upper,hinge=left,open=false + id: ${internal_id} + facing=south,half=upper,hinge=right,open=false,powered=true: + appearance: facing=south,half=upper,hinge=right,open=false + id: ${internal_id} + facing=south,half=upper,hinge=right,open=false,powered=false: + appearance: facing=south,half=upper,hinge=right,open=false + id: ${internal_id} + facing=west,half=lower,hinge=left,open=false,powered=true: + appearance: facing=west,half=lower,hinge=left,open=false + id: ${internal_id} + facing=west,half=lower,hinge=left,open=false,powered=false: + appearance: facing=west,half=lower,hinge=left,open=false + id: ${internal_id} + facing=west,half=lower,hinge=right,open=false,powered=true: + appearance: facing=west,half=lower,hinge=right,open=false + id: ${internal_id} + facing=west,half=lower,hinge=right,open=false,powered=false: + appearance: facing=west,half=lower,hinge=right,open=false + id: ${internal_id} + facing=west,half=upper,hinge=left,open=false,powered=true: + appearance: facing=west,half=upper,hinge=left,open=false + id: ${internal_id} + facing=west,half=upper,hinge=left,open=false,powered=false: + appearance: facing=west,half=upper,hinge=left,open=false + id: ${internal_id} + facing=west,half=upper,hinge=right,open=false,powered=true: + appearance: facing=west,half=upper,hinge=right,open=false + id: ${internal_id} + facing=west,half=upper,hinge=right,open=false,powered=false: + appearance: facing=west,half=upper,hinge=right,open=false + id: ${internal_id} + facing=east,half=lower,hinge=left,open=true,powered=true: + appearance: facing=east,half=lower,hinge=left,open=true + id: ${internal_id} + facing=east,half=lower,hinge=left,open=true,powered=false: + appearance: facing=east,half=lower,hinge=left,open=true + id: ${internal_id} + facing=east,half=lower,hinge=right,open=true,powered=true: + appearance: facing=east,half=lower,hinge=right,open=true + id: ${internal_id} + facing=east,half=lower,hinge=right,open=true,powered=false: + appearance: facing=east,half=lower,hinge=right,open=true + id: ${internal_id} + facing=east,half=upper,hinge=left,open=true,powered=true: + appearance: facing=east,half=upper,hinge=left,open=true + id: ${internal_id} + facing=east,half=upper,hinge=left,open=true,powered=false: + appearance: facing=east,half=upper,hinge=left,open=true + id: ${internal_id} + facing=east,half=upper,hinge=right,open=true,powered=true: + appearance: facing=east,half=upper,hinge=right,open=true + id: ${internal_id} + facing=east,half=upper,hinge=right,open=true,powered=false: + appearance: facing=east,half=upper,hinge=right,open=true + id: ${internal_id} + facing=north,half=lower,hinge=left,open=true,powered=true: + appearance: facing=north,half=lower,hinge=left,open=true + id: ${internal_id} + facing=north,half=lower,hinge=left,open=true,powered=false: + appearance: facing=north,half=lower,hinge=left,open=true + id: ${internal_id} + facing=north,half=lower,hinge=right,open=true,powered=true: + appearance: facing=north,half=lower,hinge=right,open=true + id: ${internal_id} + facing=north,half=lower,hinge=right,open=true,powered=false: + appearance: facing=north,half=lower,hinge=right,open=true + id: ${internal_id} + facing=north,half=upper,hinge=left,open=true,powered=true: + appearance: facing=north,half=upper,hinge=left,open=true + id: ${internal_id} + facing=north,half=upper,hinge=left,open=true,powered=false: + appearance: facing=north,half=upper,hinge=left,open=true + id: ${internal_id} + facing=north,half=upper,hinge=right,open=true,powered=true: + appearance: facing=north,half=upper,hinge=right,open=true + id: ${internal_id} + facing=north,half=upper,hinge=right,open=true,powered=false: + appearance: facing=north,half=upper,hinge=right,open=true + id: ${internal_id} + facing=south,half=lower,hinge=left,open=true,powered=true: + appearance: facing=south,half=lower,hinge=left,open=true + id: ${internal_id} + facing=south,half=lower,hinge=left,open=true,powered=false: + appearance: facing=south,half=lower,hinge=left,open=true + id: ${internal_id} + facing=south,half=lower,hinge=right,open=true,powered=true: + appearance: facing=south,half=lower,hinge=right,open=true + id: ${internal_id} + facing=south,half=lower,hinge=right,open=true,powered=false: + appearance: facing=south,half=lower,hinge=right,open=true + id: ${internal_id} + facing=south,half=upper,hinge=left,open=true,powered=true: + appearance: facing=south,half=upper,hinge=left,open=true + id: ${internal_id} + facing=south,half=upper,hinge=left,open=true,powered=false: + appearance: facing=south,half=upper,hinge=left,open=true + id: ${internal_id} + facing=south,half=upper,hinge=right,open=true,powered=true: + appearance: facing=south,half=upper,hinge=right,open=true + id: ${internal_id} + facing=south,half=upper,hinge=right,open=true,powered=false: + appearance: facing=south,half=upper,hinge=right,open=true + id: ${internal_id} + facing=west,half=lower,hinge=left,open=true,powered=true: + appearance: facing=west,half=lower,hinge=left,open=true + id: ${internal_id} + facing=west,half=lower,hinge=left,open=true,powered=false: + appearance: facing=west,half=lower,hinge=left,open=true + id: ${internal_id} + facing=west,half=lower,hinge=right,open=true,powered=true: + appearance: facing=west,half=lower,hinge=right,open=true + id: ${internal_id} + facing=west,half=lower,hinge=right,open=true,powered=false: + appearance: facing=west,half=lower,hinge=right,open=true + id: ${internal_id} + facing=west,half=upper,hinge=left,open=true,powered=true: + appearance: facing=west,half=upper,hinge=left,open=true + id: ${internal_id} + facing=west,half=upper,hinge=left,open=true,powered=false: + appearance: facing=west,half=upper,hinge=left,open=true + id: ${internal_id} + facing=west,half=upper,hinge=right,open=true,powered=true: + appearance: facing=west,half=upper,hinge=right,open=true + id: ${internal_id} + facing=west,half=upper,hinge=right,open=true,powered=false: + appearance: facing=west,half=upper,hinge=right,open=true + id: ${internal_id} # recipes templates#recipes: diff --git a/common-files/src/main/resources/resources/default/resourcepack/assets/minecraft/textures/item/custom/palm_door.png b/common-files/src/main/resources/resources/default/resourcepack/assets/minecraft/textures/item/custom/palm_door.png new file mode 100644 index 000000000..7128688a3 Binary files /dev/null and b/common-files/src/main/resources/resources/default/resourcepack/assets/minecraft/textures/item/custom/palm_door.png differ diff --git a/core/src/main/java/net/momirealms/craftengine/core/block/AbstractCustomBlock.java b/core/src/main/java/net/momirealms/craftengine/core/block/AbstractCustomBlock.java index 72ce3af52..32c473c61 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/block/AbstractCustomBlock.java +++ b/core/src/main/java/net/momirealms/craftengine/core/block/AbstractCustomBlock.java @@ -194,4 +194,9 @@ public abstract class AbstractCustomBlock implements CustomBlock { } return state; } + + @Override + public void setPlacedBy(BlockPlaceContext context, ImmutableBlockState state) { + this.behavior.setPlacedBy(context, state); + } } diff --git a/core/src/main/java/net/momirealms/craftengine/core/block/BlockBehavior.java b/core/src/main/java/net/momirealms/craftengine/core/block/BlockBehavior.java index c01b5e4a8..b4be523d7 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/block/BlockBehavior.java +++ b/core/src/main/java/net/momirealms/craftengine/core/block/BlockBehavior.java @@ -95,6 +95,9 @@ public abstract class BlockBehavior { return state; } + public void setPlacedBy(BlockPlaceContext context, ImmutableBlockState state) { + } + public InteractionResult useOnBlock(UseOnContext context, ImmutableBlockState state) { return InteractionResult.PASS; } diff --git a/core/src/main/java/net/momirealms/craftengine/core/block/CustomBlock.java b/core/src/main/java/net/momirealms/craftengine/core/block/CustomBlock.java index 0ff330d4b..4e835b7fc 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/block/CustomBlock.java +++ b/core/src/main/java/net/momirealms/craftengine/core/block/CustomBlock.java @@ -37,6 +37,8 @@ public interface CustomBlock { ImmutableBlockState getStateForPlacement(BlockPlaceContext context); + void setPlacedBy(BlockPlaceContext context, ImmutableBlockState state); + interface Builder { Builder events(Map>> events); diff --git a/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java b/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java index ace40069b..14aefaab7 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java +++ b/core/src/main/java/net/momirealms/craftengine/core/pack/AbstractPackManager.java @@ -427,6 +427,7 @@ public abstract class AbstractPackManager implements PackManager { plugin.saveResource("resources/default/resourcepack/assets/minecraft/textures/block/custom/palm_trapdoor.png"); plugin.saveResource("resources/default/resourcepack/assets/minecraft/textures/block/custom/palm_door_top.png"); plugin.saveResource("resources/default/resourcepack/assets/minecraft/textures/block/custom/palm_door_bottom.png"); + plugin.saveResource("resources/default/resourcepack/assets/minecraft/textures/item/custom/palm_door.png"); // plants plugin.saveResource("resources/default/configuration/plants.yml"); plugin.saveResource("resources/default/resourcepack/assets/minecraft/textures/block/custom/fairy_flower_1.png");