Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
odtheking committed Jan 2, 2024
2 parents 62f49bf + 4eb9d83 commit e45cd72
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 202 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,36 @@ private void onUpdateBlockBounds(IBlockState state, CallbackInfo ci)
{
if (SecretHitboxes.INSTANCE.getEnabled() && SecretHitboxes.INSTANCE.getButton())
{
SecretHitboxes.INSTANCE.getExpandedButtons().put(this, state);

if (SecretHitboxes.INSTANCE.getEnabled())
{
EnumFacing enumfacing = state.getValue(BlockButton.FACING);
boolean flag = state.getValue(BlockButton.POWERED);
float f2 = (flag ? 1 : 2) / 16.0f;

switch (enumfacing) {
case EAST:
this.setBlockBounds(0.0f, 0.0f, 0.0f, f2, 1.0f, 1.0f);
break;

case WEST:
this.setBlockBounds(1.0f - f2, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);
break;

case SOUTH:
this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, f2);
break;

case NORTH:
this.setBlockBounds(0.0f, 0.0f, 1.0f - f2, 1.0f, 1.0f, 1.0f);
break;

case UP:
this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.0f + f2, 1.0f);
break;

case DOWN:
this.setBlockBounds(0.0f, 1.0f - f2, 0.0f, 1.0f, 1.0f, 1.0f);
break;
}
ci.cancel();
EnumFacing enumfacing = state.getValue(BlockButton.FACING);
boolean flag = state.getValue(BlockButton.POWERED);
float f2 = (flag ? 1 : 2) / 16.0f;

switch (enumfacing) {
case EAST:
this.setBlockBounds(0.0f, 0.0f, 0.0f, f2, 1.0f, 1.0f);
break;

case WEST:
this.setBlockBounds(1.0f - f2, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);
break;

case SOUTH:
this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, f2);
break;

case NORTH:
this.setBlockBounds(0.0f, 0.0f, 1.0f - f2, 1.0f, 1.0f, 1.0f);
break;

case UP:
this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.0f + f2, 1.0f);
break;

case DOWN:
this.setBlockBounds(0.0f, 1.0f - f2, 0.0f, 1.0f, 1.0f, 1.0f);
break;
}
ci.cancel();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package me.odinclient.mixin.mixins;

import me.odinclient.features.impl.dungeon.SecretHitboxes;
import net.minecraft.block.Block;
import net.minecraft.block.BlockChest;
import net.minecraft.block.material.Material;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
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.CallbackInfo;

@Mixin(BlockChest.class)
public class MixinBlockChest extends Block {

public MixinBlockChest(Material materialIn) {
super(materialIn);
}

@Inject(method = "setBlockBoundsBasedOnState", at = @At("HEAD"), cancellable = true)
private void onSetBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos, CallbackInfo ci) {
if (SecretHitboxes.INSTANCE.getChests() && SecretHitboxes.INSTANCE.getEnabled()) {
this.setBlockBounds(0, 0, 0, 1, 1, 1);
ci.cancel();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import static net.minecraft.block.BlockLever.FACING;

@Mixin(BlockLever.class)
public class MixinBlockLever extends Block {

Expand All @@ -27,7 +25,6 @@ private void onSetBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos, Ca
if (SecretHitboxes.INSTANCE.getLever())
{
if (pos.getX() >= 58 && pos.getX() <= 62 && pos.getY() >= 133 && pos.getY() <= 136 && pos.getZ() == 142) { return; }
SecretHitboxes.INSTANCE.getExpandedLevers().put(this, worldIn.getBlockState(pos).getValue(FACING));

if (SecretHitboxes.INSTANCE.getEnabled())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,10 @@ public MixinBlockSkull(Material materialIn)
@Inject(method = "setBlockBoundsBasedOnState", at = @At("HEAD"), cancellable = true)
private void onSetBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos, CallbackInfo ci)
{
if (SecretHitboxes.INSTANCE.addEssence(pos))
if (SecretHitboxes.INSTANCE.isEssence(pos) && SecretHitboxes.INSTANCE.getEnabled())
{
SecretHitboxes.INSTANCE.getExpandedSkulls().put(this, worldIn.getBlockState(pos).getValue(FACING));

if (SecretHitboxes.INSTANCE.getEnabled())
{
this.setBlockBounds(0, 0, 0, 1, 1, 1);
ci.cancel();
}
this.setBlockBounds(0, 0, 0, 1, 1, 1);
ci.cancel();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,176 +3,22 @@ package me.odinclient.features.impl.dungeon
import me.odinmain.features.Category
import me.odinmain.features.Module
import me.odinmain.features.settings.impl.BooleanSetting
import net.minecraft.block.Block
import net.minecraft.block.BlockButton
import net.minecraft.block.BlockLever.EnumOrientation
import net.minecraft.block.state.IBlockState
import net.minecraft.tileentity.TileEntitySkull
import net.minecraft.util.BlockPos
import net.minecraft.util.EnumFacing
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

object SecretHitboxes : Module(
name = "Secret Hitboxes",
description = "Full block Secret hitboxes.",
category = Category.DUNGEON
) {

val lever: Boolean by BooleanSetting("Lever", default = true)
val button: Boolean by BooleanSetting("Button", default = true)
val essence: Boolean by BooleanSetting("Essence", default = true)
val chests: Boolean by BooleanSetting("Chests", default = true)

var expandedLevers: HashMap<Block, EnumOrientation> = HashMap()
var expandedButtons: HashMap<Block, IBlockState> = HashMap()
var expandedSkulls: HashMap<Block, EnumFacing> = HashMap()

@SubscribeEvent
fun onWorldUnLoad(event: WorldEvent.Unload)
{
this.expandedLevers.clear()
this.expandedButtons.clear()
this.expandedSkulls.clear()
}

fun addEssence(blockPos: BlockPos): Boolean {
fun isEssence(blockPos: BlockPos): Boolean {
return essence && (mc.theWorld.getTileEntity(blockPos) as? TileEntitySkull)?.playerProfile?.id?.toString() == "26bb1a8d-7c66-31c6-82d5-a9c04c94fb02"
}

override fun onEnable() {
if (lever) expandedLevers.forEach { (k, _) ->
k.setBlockBounds(0f, 0f, 0f, 1f, 1f, 1f)
}

if (button) expandedButtons.forEach { (key, value) ->
val enumfacing: EnumFacing = value.getValue(BlockButton.FACING)
val flag: Boolean = value.getValue(BlockButton.POWERED)
val f2 = (if (flag) 1 else 2).toFloat() / 16.0f
when (enumfacing) {
EnumFacing.EAST -> {
key.setBlockBounds(0.0f, 0.0f, 0.0f, f2, 1.0f, 1.0f)
}

EnumFacing.WEST -> {
key.setBlockBounds(1.0f - f2, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f)
}

EnumFacing.SOUTH -> {
key.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, f2)
}

EnumFacing.NORTH -> {
key.setBlockBounds(0.0f, 0.0f, 1.0f - f2, 1.0f, 1.0f, 1.0f)
}

EnumFacing.UP -> {
key.setBlockBounds(0.0f, 0.0f, 0.0f, 1f, 0.0f + f2, 1.0f)
}

EnumFacing.DOWN -> {
key.setBlockBounds(0.0f, 1.0f - f2, 0.0f, 1.0f, 1.0f, 1.0f)
}
}
}

if (essence) expandedSkulls.forEach { (k, _) ->
k.setBlockBounds(0f, 0f, 0f, 1f, 1f, 1f)
}

super.onEnable()
}

override fun onDisable() {
if (lever) {
for (lever in expandedLevers) {
var f = 0.1875f
when (lever.value) {
EnumOrientation.EAST -> {
lever.key.setBlockBounds(0.0f, 0.2f, 0.5f - f, f * 2.0f, 0.8f, 0.5f + f)
}

EnumOrientation.WEST -> {
lever.key.setBlockBounds(1.0f - f * 2.0f, 0.2f, 0.5f - f, 1.0f, 0.8f, 0.5f + f)
}

EnumOrientation.SOUTH -> {
lever.key.setBlockBounds(0.5f - f, 0.2f, 0.0f, 0.5f + f, 0.8f, f * 2.0f)
}

EnumOrientation.NORTH -> {
lever.key.setBlockBounds(0.5f - f, 0.2f, 1.0f - f * 2.0f, 0.5f + f, 0.8f, 1.0f)
}

EnumOrientation.UP_Z, EnumOrientation.UP_X -> {
f = 0.25f
lever.key.setBlockBounds(0.5f - f, 0.0f, 0.5f - f, 0.5f + f, 0.6f, 0.5f + f)
}

EnumOrientation.DOWN_X, EnumOrientation.DOWN_Z -> {
f = 0.25f
lever.key.setBlockBounds(0.5f - f, 0.4f, 0.5f - f, 0.5f + f, 1.0f, 0.5f + f)
}
}
}
}

if (button) {
for (button in expandedButtons) {
val enumfacing: EnumFacing = button.value.getValue(BlockButton.FACING)
val flag: Boolean = button.value.getValue(BlockButton.POWERED)
val f2 = (if (flag) 1 else 2).toFloat() / 16.0f
when (enumfacing) {
EnumFacing.EAST -> {
button.key.setBlockBounds(0.0f, 0.375f, 0.3125f, f2, 0.625f, 0.6875f)
}

EnumFacing.WEST -> {
button.key.setBlockBounds(1.0f - f2, 0.375f, 0.3125f, 1.0f, 0.625f, 0.6875f)
}

EnumFacing.SOUTH -> {
button.key.setBlockBounds(0.3125f, 0.375f, 0.0f, 0.6875f, 0.625f, f2)
}

EnumFacing.NORTH -> {
button.key.setBlockBounds(0.3125f, 0.375f, 1.0f - f2, 0.6875f, 0.625f, 1.0f)
}

EnumFacing.UP -> {
button.key.setBlockBounds(0.3125f, 0.0f, 0.375f, 0.6875f, 0.0f + f2, 0.625f)
}

EnumFacing.DOWN -> {
button.key.setBlockBounds(0.3125f, 1.0f - f2, 0.375f, 0.6875f, 1.0f, 0.625f)
}
}
}
}

if (essence) {
for (skull in expandedSkulls) {
when (skull.value) {
EnumFacing.NORTH -> {
skull.key.setBlockBounds(0.25f, 0.25f, 0.5f, 0.75f, 0.75f, 1.0f)
}

EnumFacing.SOUTH -> {
skull.key.setBlockBounds(0.25f, 0.25f, 0.0f, 0.75f, 0.75f, 0.5f)
}

EnumFacing.WEST -> {
skull.key.setBlockBounds(0.5f, 0.25f, 0.25f, 1.0f, 0.75f, 0.75f)
}

EnumFacing.EAST -> {
skull.key.setBlockBounds(0.0f, 0.25f, 0.25f, 0.5f, 0.75f, 0.75f)
}

else -> {
skull.key.setBlockBounds(0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f)
}
}
}
}
super.onDisable()
}
}
1 change: 1 addition & 0 deletions odinclient/src/main/resources/mixins.odinclient.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"compatibilityLevel": "JAVA_8",
"mixins": [
"accessors.IBlockAccessor",
"mixins.MixinBlockChest",
"mixins.MixinBlock",
"mixins.MixinBlockCocoa",
"mixins.MixinBlockCrops",
Expand Down

0 comments on commit e45cd72

Please sign in to comment.