-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from ExternalTime/old-levers
Added feature changing lever hitboxes to ones from 1.8
- Loading branch information
Showing
5 changed files
with
79 additions
and
1 deletion.
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
31 changes: 31 additions & 0 deletions
31
src/main/java/me/xmrvizzy/skyblocker/mixin/LeverBlockMixin.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,31 @@ | ||
package me.xmrvizzy.skyblocker.mixin; | ||
|
||
import me.xmrvizzy.skyblocker.skyblock.dungeon.OldLever; | ||
import me.xmrvizzy.skyblocker.utils.Utils; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.LeverBlock; | ||
import net.minecraft.block.ShapeContext; | ||
import net.minecraft.block.WallMountedBlock; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.shape.VoxelShape; | ||
import net.minecraft.world.BlockView; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(LeverBlock.class) | ||
public abstract class LeverBlockMixin extends WallMountedBlock { | ||
protected LeverBlockMixin(Settings settings) { | ||
super(settings); | ||
} | ||
|
||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) | ||
public void onGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) { | ||
if (Utils.isSkyblock) { | ||
VoxelShape shape = OldLever.getShape(state.get(FACE), state.get(FACING)); | ||
if (shape != null) | ||
cir.setReturnValue(shape); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/OldLever.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,44 @@ | ||
package me.xmrvizzy.skyblocker.skyblock.dungeon; | ||
|
||
import me.xmrvizzy.skyblocker.config.SkyblockerConfig; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.enums.WallMountLocation; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.util.shape.VoxelShape; | ||
|
||
public class OldLever { | ||
protected static final VoxelShape FLOOR_SHAPE; | ||
protected static final VoxelShape NORTH_SHAPE; | ||
protected static final VoxelShape SOUTH_SHAPE; | ||
protected static final VoxelShape EAST_SHAPE; | ||
protected static final VoxelShape WEST_SHAPE; | ||
|
||
public static VoxelShape getShape(WallMountLocation wallMountLocation, Direction direction) { | ||
if (!SkyblockerConfig.get().locations.dungeons.oldLevers) | ||
return null; | ||
|
||
if (wallMountLocation == WallMountLocation.FLOOR) { | ||
return FLOOR_SHAPE; | ||
} else if (wallMountLocation == WallMountLocation.WALL) { | ||
switch (direction) { | ||
case EAST: | ||
return EAST_SHAPE; | ||
case WEST: | ||
return WEST_SHAPE; | ||
case SOUTH: | ||
return SOUTH_SHAPE; | ||
case NORTH: | ||
return NORTH_SHAPE; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
static { | ||
FLOOR_SHAPE = Block.createCuboidShape(4, 0, 4, 12, 10, 12); | ||
NORTH_SHAPE = Block.createCuboidShape(5.0D, 3.0D, 10.0D, 11.0D, 13.0D, 16.0D); | ||
SOUTH_SHAPE = Block.createCuboidShape(5.0D, 3.0D, 0.0D, 11.0D, 13.0D, 6.0D); | ||
WEST_SHAPE = Block.createCuboidShape(10.0D, 3.0D, 5.0D, 16.0D, 13.0D, 11.0D); | ||
EAST_SHAPE = Block.createCuboidShape(0.0D, 3.0D, 5.0D, 6.0D, 13.0D, 11.0D); | ||
} | ||
} |
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