Switch to Diameter from Radius

This commit is contained in:
oitsjustjose 2022-10-17 01:07:29 -05:00
commit 09b43ed2af
2 changed files with 42 additions and 49 deletions

View file

@ -181,90 +181,83 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc
AttachFace face = state.getValue(FACE); AttachFace face = state.getValue(FACE);
int startX, endX, startY, endY, startZ, endZ; int startX, endX, startY, endY, startZ, endZ;
startX = endX = startY = endY = startZ = endZ = 0;
switch (face) { switch (face) {
case FLOOR -> { case FLOOR -> {
if (direction.getAxis() == Direction.Axis.X) { if (direction.getAxis() == Direction.Axis.X) {
startX = pos.getX() - height; startX = pos.getX() - (int) Math.floor(height / 2F);
endX = pos.getX() + height + 1; endX = pos.getX() + (int) Math.ceil(height / 2F);
startY = pos.getY() - depth; startY = pos.getY() - depth;
endY = pos.getY(); endY = pos.getY();
startZ = pos.getZ() - width; startZ = pos.getZ() - (int) Math.floor(width / 2F) + 1;
endZ = pos.getZ() + width + 1; endZ = pos.getZ() + (int) Math.ceil(width / 2F) + 1;
} else { } else {
startX = pos.getX() - width; startX = pos.getX() - (int) Math.floor(width / 2F);
endX = pos.getX() + width + 1; endX = pos.getX() + (int) Math.ceil(width / 2F);
startY = pos.getY() - depth; startY = pos.getY() - depth;
endY = pos.getY(); endY = pos.getY();
startZ = pos.getZ() - height; startZ = pos.getZ() - (int) Math.floor(height / 2F);
endZ = pos.getZ() + height + 1; endZ = pos.getZ() + (int) Math.ceil(height / 2F);
} }
this._explode(level, startX, startY, startZ, endX, endY, endZ);
} }
case WALL -> { case WALL -> {
switch (direction) { switch (direction) {
case NORTH -> { case NORTH -> {
startX = pos.getX() - width; startX = pos.getX() - (int) Math.floor(width / 2F);
endX = pos.getX() + width + 1; endX = pos.getX() + (int) Math.ceil(width / 2F);
startY = pos.getY() - height; startY = pos.getY() - (int) Math.floor(height / 2F);
endY = pos.getY() + height + 1; endY = pos.getY() + (int) Math.ceil(height / 2F);
startZ = pos.getZ() + 1; startZ = pos.getZ();
endZ = pos.getZ() + depth + 1; endZ = pos.getZ() + depth;
} }
case SOUTH -> { case SOUTH -> {
startX = pos.getX() - width; startX = pos.getX() - (int) Math.ceil(width / 2F) + 1;
endX = pos.getX() + width + 1; endX = pos.getX() + (int) Math.floor(width / 2F) + 1;
startY = pos.getY() - height; startY = pos.getY() - (int) Math.ceil(height / 2F);
endY = pos.getY() + height + 1; endY = pos.getY() + (int) Math.floor(height / 2F);
startZ = pos.getZ() - depth; startZ = pos.getZ() - depth;
endZ = pos.getZ(); endZ = pos.getZ();
} }
case EAST -> { case EAST -> {
startX = pos.getX() - depth; startX = pos.getX() - depth;
endX = pos.getX(); endX = pos.getX();
startY = pos.getY() - height; startY = pos.getY() - (int) Math.floor(height / 2F);
endY = pos.getY() + height + 1; endY = pos.getY() + (int) Math.ceil(height / 2F);
startZ = pos.getZ() - width; startZ = pos.getZ() - (int) Math.floor(width / 2F);
endZ = pos.getZ() + width + 1; endZ = pos.getZ() + (int) Math.ceil(width / 2F);
} }
case WEST -> { case WEST -> {
startX = pos.getX() + 1; startX = pos.getX();
endX = pos.getX() + depth + 1; endX = pos.getX() + depth;
startY = pos.getY() - height; startY = pos.getY() - (int) Math.ceil(height / 2F);
endY = pos.getY() + height + 1; endY = pos.getY() + (int) Math.floor(height / 2F);
startZ = pos.getZ() - width; startZ = pos.getZ() - (int) Math.ceil(width / 2F) + 1;
endZ = pos.getZ() + width + 1; endZ = pos.getZ() + (int) Math.floor(width / 2F) + 1;
} }
default -> { default -> {
//NOOP break;
startX = 0;
endX = 0;
startY = 0;
endY = 0;
startZ = 0;
endZ = 0;
} }
} }
this._explode(level, startX, startY, startZ, endX, endY, endZ);
} }
case CEILING -> { case CEILING -> {
if (direction.getAxis() == Direction.Axis.X) { if (direction.getAxis() == Direction.Axis.X) {
startX = pos.getX() - height; startX = pos.getX() - (int) Math.floor(height / 2F);
endX = pos.getX() + height + 1; endX = pos.getX() + (int) Math.ceil(height / 2F);
startY = pos.getY(); startY = pos.getY();
endY = pos.getY() + depth + 1; endY = pos.getY() + depth;
startZ = pos.getZ() - width; startZ = pos.getZ() - (int) Math.floor(width / 2F);
endZ = pos.getZ() + width + 1; endZ = pos.getZ() + (int) Math.ceil(width / 2F);
} else { } else {
startX = pos.getX() - width; startX = pos.getX() - (int) Math.floor(width / 2F) + 1;
endX = pos.getX() + width + 1; endX = pos.getX() + (int) Math.ceil(width / 2F) + 1;
startY = pos.getY(); startY = pos.getY();
endY = pos.getY() + depth + 1; endY = pos.getY() + depth;
startZ = pos.getZ() - height; startZ = pos.getZ() - (int) Math.floor(height / 2F);
endZ = pos.getZ() + height + 1; endZ = pos.getZ() + (int) Math.ceil(height / 2F);
} }
this._explode(level, startX, startY, startZ, endX, endY, endZ);
} }
} }
this._explode(level, startX, startY, startZ, endX, endY, endZ);
level.playSound(null, pos, SoundEvents.GENERIC_EXPLODE, SoundSource.BLOCKS, 1.0F, 1.0F); level.playSound(null, pos, SoundEvents.GENERIC_EXPLODE, SoundSource.BLOCKS, 1.0F, 1.0F);
} }

View file

@ -1,5 +1,5 @@
{ {
"charged_explosives.explosion.configuration.title": "Configure Blast Radius", "charged_explosives.explosion.configuration.title": "Configure Blast Range",
"charged_explosives.explosion.width.title": "Explosion Width:", "charged_explosives.explosion.width.title": "Explosion Width:",
"charged_explosives.explosion.height.title": "Explosion Height:", "charged_explosives.explosion.height.title": "Explosion Height:",
"charged_explosives.explosion.depth.title": "Explosion Depth:", "charged_explosives.explosion.depth.title": "Explosion Depth:",