Fixed crash when placing ladders. Tweaked circle, cylinder and sphere to have the same outer radius whether they are full or hollow.

This commit is contained in:
Christian Knaapen
2019-12-23 13:08:02 +01:00
parent 83b23fe763
commit 4e3b1ef2ce
5 changed files with 17 additions and 12 deletions

View File

@@ -41,7 +41,7 @@ public class Circle extends TwoClicksBuildMode {
if (ModeOptions.getFill() == ModeOptions.ActionEnum.FULL)
addCircleBlocks(list, x1, y1, z1, x2, y2, z2, centerX, centerZ, radiusX, radiusZ);
else
addHollowCircleBlocks(list, x1, y1, z1, x2, y2, z2, centerX, centerZ, radiusX, radiusZ, 1f);
addHollowCircleBlocks(list, x1, y1, z1, x2, y2, z2, centerX, centerZ, radiusX, radiusZ);
return list;
}
@@ -60,7 +60,7 @@ public class Circle extends TwoClicksBuildMode {
}
}
public static void addHollowCircleBlocks(List<BlockPos> list, int x1, int y1, int z1, int x2, int y2, int z2, float centerX, float centerZ, float radiusX, float radiusZ, float thickness) {
public static void addHollowCircleBlocks(List<BlockPos> list, int x1, int y1, int z1, int x2, int y2, int z2, float centerX, float centerZ, float radiusX, float radiusZ) {
for (int l = x1; x1 < x2 ? l <= x2 : l >= x2; l += x1 < x2 ? 1 : -1) {
@@ -68,7 +68,7 @@ public class Circle extends TwoClicksBuildMode {
float distance = distance(l, n, centerX, centerZ);
float radius = calculateEllipseRadius(centerX, centerZ, radiusX, radiusZ, l, n);
if (distance < radius + (thickness / 2f) && distance > radius - (thickness / 2f))
if (distance < radius + 0.4f && distance > radius - 0.6f)
list.add(new BlockPos(l, y1, n));
}
}

View File

@@ -56,7 +56,7 @@ public class Sphere extends ThreeClicksBuildMode {
if (ModeOptions.getFill() == ModeOptions.ActionEnum.FULL)
addSphereBlocks(list, x1, y1, z1, x3, y3, z3, centerX, centerY, centerZ, radiusX, radiusY, radiusZ);
else
addHollowSphereBlocks(list, x1, y1, z1, x3, y3, z3, centerX, centerY, centerZ, radiusX, radiusY, radiusZ, 1f);
addHollowSphereBlocks(list, x1, y1, z1, x3, y3, z3, centerX, centerY, centerZ, radiusX, radiusY, radiusZ);
return list;
}
@@ -71,7 +71,7 @@ public class Sphere extends ThreeClicksBuildMode {
float distance = distance(l, m, n, centerX, centerY, centerZ);
float radius = calculateSpheroidRadius(centerX, centerY, centerZ, radiusX, radiusY, radiusZ, l, m, n);
if (distance < radius + 0.5f)
if (distance < radius + 0.4f)
list.add(new BlockPos(l, m, n));
}
}
@@ -79,7 +79,7 @@ public class Sphere extends ThreeClicksBuildMode {
}
public static void addHollowSphereBlocks(List<BlockPos> list, int x1, int y1, int z1, int x2, int y2, int z2,
float centerX, float centerY, float centerZ, float radiusX, float radiusY, float radiusZ, float thickness) {
float centerX, float centerY, float centerZ, float radiusX, float radiusY, float radiusZ) {
for (int l = x1; x1 < x2 ? l <= x2 : l >= x2; l += x1 < x2 ? 1 : -1) {
for (int n = z1; z1 < z2 ? n <= z2 : n >= z2; n += z1 < z2 ? 1 : -1) {
@@ -88,7 +88,7 @@ public class Sphere extends ThreeClicksBuildMode {
float distance = distance(l, m, n, centerX, centerY, centerZ);
float radius = calculateSpheroidRadius(centerX, centerY, centerZ, radiusX, radiusY, radiusZ, l, m, n);
if (distance < radius + (thickness / 2f) && distance > radius - (thickness / 2f))
if (distance < radius + 0.4f && distance > radius - 0.6f)
list.add(new BlockPos(l, m, n));
}
}

View File

@@ -207,6 +207,7 @@ public class UndoRedo {
private static ItemStack findItemStackInInventory(PlayerEntity player, BlockState blockState) {
ItemStack itemStack = ItemStack.EMPTY;
if (blockState == null) return itemStack;
//First try previousBlockStates
//TODO try to find itemstack with right blockstate first

View File

@@ -193,13 +193,15 @@ public class BlockPreviewRenderer {
//if so, renew randomness of randomizer bag
ItemRandomizerBag.renewRandomness();
//and play sound (max once every tick)
if (startCoordinates.size() > 1 && blockStates.size() > 1 && soundTime < ClientProxy.ticksInGame - 0) {
if (newCoordinates.size() > 1 && blockStates.size() > 1 && soundTime < ClientProxy.ticksInGame - 0) {
soundTime = ClientProxy.ticksInGame;
SoundType soundType = blockStates.get(0).getBlock().getSoundType(blockStates.get(0), player.world,
newCoordinates.get(0), player);
player.world.playSound(player, player.getPosition(), breaking ? soundType.getBreakSound() : soundType.getPlaceSound(),
SoundCategory.BLOCKS, 0.3f, 0.8f);
if (blockStates.get(0) != null) {
SoundType soundType = blockStates.get(0).getBlock().getSoundType(blockStates.get(0), player.world,
newCoordinates.get(0), player);
player.world.playSound(player, player.getPosition(), breaking ? soundType.getBreakSound() : soundType.getPlaceSound(),
SoundCategory.BLOCKS, 0.3f, 0.8f);
}
}
}

View File

@@ -195,6 +195,8 @@ public class RenderHandler {
}
protected static void renderBlockPreview(BlockRendererDispatcher dispatcher, BlockPos blockPos, BlockState blockState) {
if (blockState == null) return;
GlStateManager.pushMatrix();
GlStateManager.translatef(blockPos.getX(), blockPos.getY(), blockPos.getZ());
GlStateManager.rotatef(-90.0F, 0.0F, 1.0F, 0.0F);