Skip to content

Commit

Permalink
add: wrappers for methods with coordinates from BlockDoor, BlockDoubl…
Browse files Browse the repository at this point in the history
…ePlant, BlockDragonEgg to BlockPos; fix: aabb absolute creation in Pos; add: IPosition to Pos;
  • Loading branch information
MJaroslav committed Feb 19, 2024
1 parent 03b647d commit 1d3c2db
Show file tree
Hide file tree
Showing 7 changed files with 266 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
@Mixin(Block.class)
public interface AccessorBlock {
@Invoker("dropBlockAsItem")
void invokeDropBlockAsItem(@NotNull World world, int x, int y, int z, @NotNull ItemStack stack);
void dropBlockAsItem(@NotNull World world, int x, int y, int z, @NotNull ItemStack stack);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

@Mixin(BlockDispenser.class)
public interface AccessorBlockDispenser {
@Invoker("func_149938_m")
void rotateBlockToFreeSide(@NotNull World world, int x, int y, int z);

@Invoker("func_149941_e")
void updateAndPlayEffects(@NotNull World world, int x, int y, int z);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.github.mjaroslav.mjutils.asm.mixin.accessors;

import net.minecraft.block.BlockDoublePlant;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(BlockDoublePlant.class)
public interface AccessorBlockDoublePlant {
@Invoker("func_149886_b")
boolean dropBlockAndAddStat(@NotNull World world, int x, int y, int z, int meta, @NotNull EntityPlayer harvester);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.github.mjaroslav.mjutils.asm.mixin.accessors;

import net.minecraft.block.BlockDragonEgg;
import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(BlockDragonEgg.class)
public interface AccessorBlockDragonEgg {
@Invoker("func_150018_e")
void checkAndFall(@NotNull World world, int x, int y, int z);

@Invoker("func_150019_m")
void moveRandomly(@NotNull World world, int x, int y, int z);
}
67 changes: 66 additions & 1 deletion src/main/java/io/github/mjaroslav/mjutils/pos/BlockPos.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void dropBlockAsItemWithChance(@NotNull Block owner, @NotNull World world
public void dropBlockAsItem(@NotNull Block owner, @NotNull World world,
@NotNull Triplet<? extends Number, ? extends Number, ? extends Number> pos,
@NotNull ItemStack stack) {
((AccessorBlock) owner).invokeDropBlockAsItem(world, pos.getX().intValue(), pos.getY().intValue(),
((AccessorBlock) owner).dropBlockAsItem(world, pos.getX().intValue(), pos.getY().intValue(),
pos.getZ().intValue(), stack);
}

Expand Down Expand Up @@ -791,6 +791,13 @@ public boolean getWeakChanges(@NotNull Block owner, @NotNull IBlockAccess world,

//region BlockDispenser
//--------------------------
public void dispenser$rotateBlockToFreeSide(@NotNull BlockDispenser owner, @NotNull World world,
@NotNull Triplet<? extends Number, ? extends Number,
? extends Number> pos) {
((AccessorBlockDispenser) owner).rotateBlockToFreeSide(world, pos.getX().intValue(), pos.getY().intValue(),
pos.getZ().intValue());
}

public void dispenser$updateAndPlayEffects(@NotNull BlockDispenser owner, @NotNull World world,
@NotNull Triplet<? extends Number, ? extends Number,
? extends Number> pos) {
Expand All @@ -800,6 +807,64 @@ public boolean getWeakChanges(@NotNull Block owner, @NotNull IBlockAccess world,
//--------------------------
//endregion

//region BlockDoor
//--------------------------
public final int DOOR$MASK_DIRECTION = 0b00011;
public final int DOOR$MASK_OPEN = 0b000100;
public final int DOOR$MASK_UPPER_BLOCK = 0b01000;
public final int DOOR$MASK_HINGE = 0b10000;

public int door$getRotation(@NotNull BlockDoor owner, @NotNull IBlockAccess world,
@NotNull Triplet<? extends Number, ? extends Number, ? extends Number> pos) {
return owner.func_150013_e(world, pos.getX().intValue(), pos.getY().intValue(), pos.getZ().intValue());
}

public boolean door$isOpen(@NotNull BlockDoor owner, @NotNull IBlockAccess world,
@NotNull Triplet<? extends Number, ? extends Number, ? extends Number> pos) {
return owner.func_150015_f(world, pos.getX().intValue(), pos.getY().intValue(), pos.getZ().intValue());
}

public void door$setOpen(@NotNull BlockDoor owner, @NotNull World world,
@NotNull Triplet<? extends Number, ? extends Number, ? extends Number> pos,
boolean open) {
owner.func_150014_a(world, pos.getX().intValue(), pos.getY().intValue(), pos.getZ().intValue(), open);
}

public int door$getBits(@NotNull BlockDoor owner, @NotNull IBlockAccess world,
@NotNull Triplet<? extends Number, ? extends Number, ? extends Number> pos) {
return owner.func_150012_g(world, pos.getX().intValue(), pos.getY().intValue(), pos.getZ().intValue());
}
//--------------------------
//endregion

//region BlockDoublePlant
//--------------------------
public boolean doublePlant$dropBlockAndAddStat(@NotNull BlockDoublePlant owner, @NotNull World world,
@NotNull Triplet<? extends Number, ? extends Number,
? extends Number> pos, int meta,
@NotNull EntityPlayer harvester) {
return ((AccessorBlockDoublePlant) owner).dropBlockAndAddStat(world, pos.getX().intValue(),
pos.getY().intValue(), pos.getZ().intValue(), meta, harvester);
}
//--------------------------
//endregion

//region BlockDragonEgg
//--------------------------
public void checkAndFall(@NotNull BlockDragonEgg owner, @NotNull World world,
@NotNull Triplet<? extends Number, ? extends Number, ? extends Number> pos) {
((AccessorBlockDragonEgg) owner).checkAndFall(world, pos.getX().intValue(), pos.getY().intValue(),
pos.getZ().intValue());
}

public void moveRandomly(@NotNull BlockDragonEgg owner, @NotNull World world,
@NotNull Triplet<? extends Number, ? extends Number, ? extends Number> pos) {
((AccessorBlockDragonEgg) owner).moveRandomly(world, pos.getX().intValue(), pos.getY().intValue(),
pos.getZ().intValue());
}
//--------------------------
//endregion

//region IGrowable
//--------------------------
public boolean growable$canGrowthByBoneMeal(@NotNull IGrowable owner, @NotNull World world,
Expand Down
Loading

1 comment on commit 1d3c2db

@tox1cozZ
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mama

Please sign in to comment.