-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check Beehive obstruction first on exit
- Loading branch information
Showing
4 changed files
with
44 additions
and
0 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
35 changes: 35 additions & 0 deletions
35
src/main/java/me/jellysquid/mods/lithium/mixin/block/beehive/BeehiveBlockEntityMixin.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,35 @@ | ||
package me.jellysquid.mods.lithium.mixin.block.beehive; | ||
|
||
import net.minecraft.block.BeehiveBlock; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.entity.BeehiveBlockEntity; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.world.World; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Coerce; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.util.List; | ||
|
||
@Mixin(BeehiveBlockEntity.class) | ||
public class BeehiveBlockEntityMixin { | ||
|
||
@Inject( | ||
method = "releaseBee", | ||
at = @At(value = "INVOKE", shift = At.Shift.BEFORE, target = "Lnet/minecraft/nbt/NbtCompound;copy()Lnet/minecraft/nbt/NbtCompound;"), | ||
cancellable = true | ||
) | ||
private static void exitEarlyIfHiveObstructed(World world, BlockPos pos, BlockState state, @Coerce Object bee, @Nullable List<Entity> entities, BeehiveBlockEntity.BeeState beeState, @Nullable BlockPos flowerPos, CallbackInfoReturnable<Boolean> cir) { | ||
Direction direction = state.get(BeehiveBlock.FACING); | ||
BlockPos blockPos = pos.offset(direction); | ||
|
||
if (beeState != BeehiveBlockEntity.BeeState.EMERGENCY && !world.getBlockState(blockPos).getCollisionShape(world, blockPos).isEmpty()) { | ||
cir.setReturnValue(false); | ||
}; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/me/jellysquid/mods/lithium/mixin/block/beehive/package-info.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,4 @@ | ||
@MixinConfigOption(description = "Beehives check if they are obstructed before performing expensive nbt copy operations for each exit attempt.") | ||
package me.jellysquid.mods.lithium.mixin.block.beehive; | ||
|
||
import net.caffeinemc.gradle.MixinConfigOption; |
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