|
10 | 10 | import net.minecraft.resources.ResourceLocation;
|
11 | 11 | import net.minecraft.sounds.SoundEvents;
|
12 | 12 | import net.minecraft.sounds.SoundSource;
|
| 13 | +import net.minecraft.tags.BlockTags; |
13 | 14 | import net.minecraft.tags.ItemTags;
|
14 | 15 | import net.minecraft.tags.TagKey;
|
15 | 16 | import net.minecraft.world.InteractionHand;
|
@@ -65,10 +66,12 @@ public class EnhancedLaddersModule extends ZetaModule {
|
65 | 66 |
|
66 | 67 | private static boolean staticEnabled;
|
67 | 68 | private static TagKey<Item> laddersTag;
|
| 69 | + private static TagKey<Block> laddersBlockTag; |
68 | 70 |
|
69 | 71 | @LoadEvent
|
70 | 72 | public final void setup(ZCommonSetup event) {
|
71 | 73 | laddersTag = ItemTags.create(new ResourceLocation(Quark.MOD_ID, "ladders"));
|
| 74 | + laddersBlockTag = BlockTags.create(new ResourceLocation(Quark.MOD_ID, "ladders")); |
72 | 75 | }
|
73 | 76 |
|
74 | 77 | @LoadEvent
|
@@ -116,31 +119,26 @@ private static boolean canAttachTo(BlockState state, Block ladder, LevelReader w
|
116 | 119 | return false;
|
117 | 120 | }
|
118 | 121 |
|
| 122 | + // replaces ladder survives logic |
119 | 123 | public static boolean canLadderSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
120 | 124 | if(!staticEnabled || !allowFreestanding)
|
121 | 125 | return false;
|
| 126 | + if(!state.is(laddersBlockTag))return false; |
122 | 127 |
|
123 | 128 | Direction facing = state.getValue(LadderBlock.FACING);
|
124 | 129 | Direction opposite = facing.getOpposite();
|
125 | 130 | BlockPos oppositePos = pos.relative(opposite);
|
126 | 131 | BlockState oppositeState = world.getBlockState(oppositePos);
|
127 | 132 |
|
128 |
| - boolean solid = facing.getAxis() != Axis.Y && oppositeState.isFaceSturdy(world, oppositePos, facing) && !(oppositeState.getBlock() instanceof LadderBlock); |
| 133 | + boolean solid = oppositeState.isFaceSturdy(world, oppositePos, facing) && !(oppositeState.getBlock() instanceof LadderBlock); |
129 | 134 | BlockState topState = world.getBlockState(pos.above());
|
130 | 135 | return solid || (topState.getBlock() instanceof LadderBlock && (facing.getAxis() == Axis.Y || topState.getValue(LadderBlock.FACING) == facing));
|
131 | 136 | }
|
132 | 137 |
|
133 |
| - public static boolean updateLadder(BlockState state, Direction facing, BlockState facingState, LevelAccessor world, BlockPos currentPos, BlockPos facingPos) { |
134 |
| - if(!staticEnabled || !allowFreestanding) |
135 |
| - return true; |
136 |
| - |
137 |
| - return canLadderSurvive(state, world, currentPos); |
138 |
| - } |
139 | 138 |
|
140 | 139 | @PlayEvent
|
141 | 140 | public void onInteract(ZRightClickBlock event) {
|
142 |
| - if(!allowDroppingDown) |
143 |
| - return; |
| 141 | + if(!allowDroppingDown) return; |
144 | 142 |
|
145 | 143 | Player player = event.getPlayer();
|
146 | 144 | InteractionHand hand = event.getHand();
|
|
0 commit comments