Skip to content

Commit

Permalink
Tweak delta movement of charges
Browse files Browse the repository at this point in the history
  • Loading branch information
WenXin20 committed Jan 2, 2025
1 parent 2970bd2 commit 204883c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
20 changes: 6 additions & 14 deletions src/main/java/com/wenxin2/marioverse/blocks/QuestionBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,31 +293,23 @@ public void spawnFromQuestionBlock(Level world, BlockPos pos, ItemStack stack, E
player.addItem(stack.copyWithCount(1));
} else if (stack.getItem() instanceof WindChargeItem) {
WindCharge windCharge = new WindCharge(serverWorld, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5,
new Vec3(0, 0, 0));
new Vec3(0, -0.5, 0));

if (!windCharge.getType().is(TagRegistry.QUESTION_BLOCK_CANNOT_SPAWN)) {
if (world.getBlockState(pos.above()).isAir() || world.getFluidState(pos.above()).is(FluidTags.WATER)) {
if (world.getBlockState(pos.above()).isAir() || world.getFluidState(pos.above()).is(FluidTags.WATER))
windCharge.setPos(pos.getX() + 0.5D, pos.getY() + 1.0D, pos.getZ() + 0.5D);
windCharge.setDeltaMovement(new Vec3(0, 0.5, 0));
} else {
windCharge.setPos(pos.getX() + 0.5D, pos.below((int) Math.max(1, windCharge.getBbHeight())).getY(), pos.getZ() + 0.5D);
windCharge.setDeltaMovement(new Vec3(0, -0.5, 0));
}
else windCharge.setPos(pos.getX() + 0.5D, pos.below((int) Math.max(1, windCharge.getBbHeight())).getY(), pos.getZ() + 0.5D);
world.addFreshEntity(windCharge);
stack.copyWithCount(1);
} else spawnItem(world, pos, stack, dropItemsAtPos);
} else if (stack.getItem() instanceof FireChargeItem) {
SmallFireball fireball = new SmallFireball(serverWorld, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5,
new Vec3(0, 0, 0));
new Vec3(0, -0.5, 0));

if (!fireball.getType().is(TagRegistry.QUESTION_BLOCK_CANNOT_SPAWN)) {
if (world.getBlockState(pos.above()).isAir() || world.getFluidState(pos.above()).is(FluidTags.WATER)) {
if (world.getBlockState(pos.above()).isAir() || world.getFluidState(pos.above()).is(FluidTags.WATER))
fireball.setPos(pos.getX() + 0.5D, pos.getY() + 1.0D, pos.getZ() + 0.5D);
fireball.setDeltaMovement(new Vec3(0, 0.5, 0));
} else {
fireball.setPos(pos.getX() + 0.5D, pos.below((int) Math.max(1, fireball.getBbHeight())).getY(), pos.getZ() + 0.5D);
fireball.setDeltaMovement(new Vec3(0, -0.5, 0));
}
else fireball.setPos(pos.getX() + 0.5D, pos.below((int) Math.max(1, fireball.getBbHeight())).getY(), pos.getZ() + 0.5D);
world.addFreshEntity(fireball);
stack.copyWithCount(1);
} else spawnItem(world, pos, stack, dropItemsAtPos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,19 @@ else if (container.getItem(i).getItem() instanceof WindChargeItem)
player.addItem(stack.copyWithCount(1));
} else if (stack.getItem() instanceof WindChargeItem) {
WindCharge windCharge = new WindCharge(serverWorld, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5,
new Vec3(0, 0, 0));
new Vec3(0, -0.5, 0));

if (!windCharge.getType().is(cannotSpawn)) {
windCharge.setPos(pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D);
windCharge.setDeltaMovement(new Vec3(0, -0.5, 0));
world.addFreshEntity(windCharge);
stack.copyWithCount(1);
} else marioverse$spawnItem(world, pos, stack);
} else if (stack.getItem() instanceof FireChargeItem) {
SmallFireball fireball = new SmallFireball(serverWorld, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5,
new Vec3(0, 0, 0));
new Vec3(0, -0.5, 0));

if (!fireball.getType().is(cannotSpawn)) {
fireball.setPos(pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D);
fireball.setDeltaMovement(new Vec3(0, -0.5, 0));
world.addFreshEntity(fireball);
stack.copyWithCount(1);
} else marioverse$spawnItem(world, pos, stack);
Expand Down

0 comments on commit 204883c

Please sign in to comment.