Skip to content

Commit

Permalink
Simplify bucket logic
Browse files Browse the repository at this point in the history
  • Loading branch information
WenXin20 committed Jan 4, 2025
1 parent da0b54f commit 729e624
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 36 deletions.
45 changes: 21 additions & 24 deletions src/main/java/com/wenxin2/marioverse/blocks/QuestionBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -375,30 +375,27 @@ public void spawnFromQuestionBlock(Level world, BlockPos pos, ItemStack stack, E
world.addFreshEntity(egg);
stack.copyWithCount(1);
} else spawnItem(world, pos, stack, dropItemsAtPos);
} else if (stack.getItem() instanceof BucketItem bucket && bucket.content != Fluids.EMPTY) {
if (ConfigRegistry.QUESTION_BUCKET_TWEAKS.get()) {
if (world.getBlockState(pos.above()).isAir() || !world.getFluidState(pos.above()).isEmpty()
|| (!world.getBlockState(pos.below()).isAir() && world.getFluidState(pos.below()).isEmpty())) {
if (bucket.emptyContents(null, world, pos.above(), null, stack))
bucket.checkExtraContent(null, world, stack, pos.above());
} else {
if (bucket.emptyContents(null, world, pos.below(), null, stack))
bucket.checkExtraContent(null, world, stack, pos.below());
}
spawnItem(world, pos, new ItemStack(Items.BUCKET), dropItemsAtPos);
} else spawnItem(world, pos, stack, dropItemsAtPos);
} else if (stack.getItem() instanceof SolidBucketItem bucket) {
if (ConfigRegistry.QUESTION_BUCKET_TWEAKS.get()) {
if (world.getBlockState(pos.above()).isAir() || !world.getFluidState(pos.above()).isEmpty()
|| (!world.getBlockState(pos.below()).isAir() && world.getFluidState(pos.below()).isEmpty())) {
if (bucket.emptyContents(null, world, pos.above(), null, stack))
bucket.checkExtraContent(null, world, stack, pos.above());
} else {
if (bucket.emptyContents(null, world, pos.below(), null, stack))
bucket.checkExtraContent(null, world, stack, pos.below());
}
spawnItem(world, pos, new ItemStack(Items.BUCKET), dropItemsAtPos);
} else spawnItem(world, pos, stack, dropItemsAtPos);
} else if (stack.getItem() instanceof BucketItem bucket && bucket.content != Fluids.EMPTY
&& ConfigRegistry.QUESTION_BUCKET_TWEAKS.get()) {
if (world.getBlockState(pos.above()).isAir() || !world.getFluidState(pos.above()).isEmpty()
|| (!world.getBlockState(pos.below()).isAir() && world.getFluidState(pos.below()).isEmpty())) {
if (bucket.emptyContents(null, world, pos.above(), null, stack))
bucket.checkExtraContent(null, world, stack, pos.above());
} else {
if (bucket.emptyContents(null, world, pos.below(), null, stack))
bucket.checkExtraContent(null, world, stack, pos.below());
}
spawnItem(world, pos, new ItemStack(Items.BUCKET), dropItemsAtPos);
} else if (stack.getItem() instanceof SolidBucketItem bucket && ConfigRegistry.QUESTION_BUCKET_TWEAKS.get()) {
if (world.getBlockState(pos.above()).isAir() || !world.getFluidState(pos.above()).isEmpty()
|| (!world.getBlockState(pos.below()).isAir() && world.getFluidState(pos.below()).isEmpty())) {
if (bucket.emptyContents(null, world, pos.above(), null, stack))
bucket.checkExtraContent(null, world, stack, pos.above());
} else {
if (bucket.emptyContents(null, world, pos.below(), null, stack))
bucket.checkExtraContent(null, world, stack, pos.below());
}
spawnItem(world, pos, new ItemStack(Items.BUCKET), dropItemsAtPos);
} else if (stack.getItem() == CompatRegistry.HAT_STAND_ITEM.get()) {
Entity entity = CompatRegistry.HAT_STAND.get().create(serverWorld);

Expand Down
21 changes: 9 additions & 12 deletions src/main/java/com/wenxin2/marioverse/mixin/ContainersMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,15 @@ private static void dropContents(Level world, double x, double y, double z, Cont
world.addFreshEntity(egg);
stack.copyWithCount(1);
} else marioverse$spawnItem(world, pos, stack);
} else if (stack.getItem() instanceof BucketItem bucket && bucket.content != Fluids.EMPTY) {
if (canEmptyBuckets) {
if (bucket.emptyContents(null, world, pos, null, stack))
bucket.checkExtraContent(null, world, stack, pos);
marioverse$spawnItem(world, pos, new ItemStack(Items.BUCKET));
} else marioverse$spawnItem(world, pos, stack);
} else if (stack.getItem() instanceof SolidBucketItem bucket) {
if (canEmptyBuckets) {
if (bucket.emptyContents(null, world, pos, null, stack))
bucket.checkExtraContent(null, world, stack, pos);
marioverse$spawnItem(world, pos, new ItemStack(Items.BUCKET));
} else marioverse$spawnItem(world, pos, stack);
} else if (stack.getItem() instanceof BucketItem bucket
&& bucket.content != Fluids.EMPTY && canEmptyBuckets) {
if (bucket.emptyContents(null, world, pos, null, stack))
bucket.checkExtraContent(null, world, stack, pos);
marioverse$spawnItem(world, pos, new ItemStack(Items.BUCKET));
} else if (stack.getItem() instanceof SolidBucketItem bucket && canEmptyBuckets) {
if (bucket.emptyContents(null, world, pos, null, stack))
bucket.checkExtraContent(null, world, stack, pos);
marioverse$spawnItem(world, pos, new ItemStack(Items.BUCKET));
} else if (stack.getItem() == CompatRegistry.HAT_STAND_ITEM.get()) {
Entity entity = CompatRegistry.HAT_STAND.get().create(serverWorld);

Expand Down

0 comments on commit 729e624

Please sign in to comment.