-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #2 i am sorry to everyone that had to wait this long for me to do…
… this
- Loading branch information
Showing
4 changed files
with
39 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/tf/ssf/sfort/lengthyladders/mixin/MixinItemsCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package tf.ssf.sfort.lengthyladders.mixin; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.LadderBlock; | ||
import net.minecraft.item.BlockItem; | ||
import net.minecraft.item.ItemPlacementContext; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(BlockItem.class) | ||
public abstract class MixinItemsCompat { | ||
@Shadow public abstract Block getBlock(); | ||
|
||
@Inject(method = "getPlacementContext(Lnet/minecraft/item/ItemPlacementContext;)Lnet/minecraft/item/ItemPlacementContext;", at=@At("HEAD"), cancellable = true) | ||
private void register(ItemPlacementContext context, CallbackInfoReturnable<ItemPlacementContext> cir){ | ||
if(this.getBlock() instanceof LadderBlock){ | ||
BlockPos hit = context.getBlockPos().offset(context.getSide().getOpposite()); | ||
BlockState state = context.getWorld().getBlockState(hit); | ||
if (state.isOf(this.getBlock()) && state.get(LadderBlock.FACING).equals(context.getSide())) { | ||
cir.setReturnValue(ItemPlacementContext.offset(context, hit.up(), Direction.DOWN)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters