Skip to content

Commit

Permalink
Added feature changing lever hitboxes to ones from 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
ExternalTime committed Oct 19, 2021
1 parent 42dd089 commit 0653f9f
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public static class Dungeons {
public boolean solveThreeWeirdos = true;
public boolean blazesolver = true;
public boolean solveTrivia = true;
public boolean oldLevers = false;
@ConfigEntry.Gui.CollapsibleObject(startExpanded = true)
public Terminals terminals = new Terminals();
}
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/me/xmrvizzy/skyblocker/mixin/LeverBlockMixin.java
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);
}
}
}
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);
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"text.autoconfig.skyblocker.option.locations.dungeons.solveThreeWeirdos": "Solve Three Weirdos Puzzle",
"text.autoconfig.skyblocker.option.locations.dungeons.blazesolver": "Solve Blaze Puzzle",
"text.autoconfig.skyblocker.option.locations.dungeons.solveTrivia": "Solve Trivia Puzzle",
"text.autoconfig.skyblocker.option.locations.dungeons.oldLevers": "1.8 lever hitbox",
"text.autoconfig.skyblocker.option.locations.dungeons.terminals": "Terminal Solvers",
"text.autoconfig.skyblocker.option.locations.dungeons.terminals.solveColor": "Solve Select Colored",
"text.autoconfig.skyblocker.option.locations.dungeons.terminals.solveOrder": "Solve Click In Order",
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/skyblocker.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"MinecraftClientMixin",
"AccessorWorldRenderer",
"GenericContainerScreenMixin",
"GenericContainerScreenHandlerMixin"
"GenericContainerScreenHandlerMixin",
"LeverBlockMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 0653f9f

Please sign in to comment.