Fixed several issues. Mirroring vertically.

Modifier panel up/down buttons updating.
Updating neighbouring blocks when placing blocks.
Removed separate icon files.
This commit is contained in:
Christian
2023-01-30 01:37:59 +01:00
parent 420b06d414
commit 953a3fe923
40 changed files with 9 additions and 24 deletions

View File

@@ -261,7 +261,7 @@ public class BlockHelper {
if (state.getBlock() instanceof BaseRailBlock) { if (state.getBlock() instanceof BaseRailBlock) {
placeRailWithoutUpdate(world, state, target); placeRailWithoutUpdate(world, state, target);
} else { } else {
world.setBlock(target, state, 18); world.setBlock(target, state, 2); //Changed flag from 18 to 3
} }
if (data != null) { if (data != null) {

View File

@@ -15,11 +15,9 @@ import net.minecraft.core.Direction;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.FormattedText; import net.minecraft.network.chat.FormattedText;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.util.RandomSource; import net.minecraft.util.RandomSource;
import nl.requios.effortlessbuilding.AllIcons;
import nl.requios.effortlessbuilding.ClientEvents; import nl.requios.effortlessbuilding.ClientEvents;
import nl.requios.effortlessbuilding.EffortlessBuilding; import nl.requios.effortlessbuilding.EffortlessBuilding;
import nl.requios.effortlessbuilding.EffortlessBuildingClient; import nl.requios.effortlessbuilding.EffortlessBuildingClient;

View File

@@ -106,6 +106,9 @@ public abstract class BaseModifierEntry<T extends BaseModifier> extends Modifier
nameLabel.y = top + 4; nameLabel.y = top + 4;
nameLabel.render(ms, mouseX, mouseY, partialTicks); nameLabel.render(ms, mouseX, mouseY, partialTicks);
moveUpButton.visible = screen.canMoveUp(this);
moveDownButton.visible = screen.canMoveDown(this);
moveUpButton.x = right - 31; moveUpButton.x = right - 31;
moveUpButton.y = top + 3; moveUpButton.y = top + 3;
moveUpButton.render(ms, mouseX, mouseY, partialTicks); moveUpButton.render(ms, mouseX, mouseY, partialTicks);
@@ -126,8 +129,5 @@ public abstract class BaseModifierEntry<T extends BaseModifier> extends Modifier
enableButton.setToolTip(Components.literal("Disable this modifier")); enableButton.setToolTip(Components.literal("Disable this modifier"));
else else
enableButton.setToolTip(Components.literal("Enable this modifier")); enableButton.setToolTip(Components.literal("Enable this modifier"));
moveUpButton.visible = screen.canMoveUp(this);
moveDownButton.visible = screen.canMoveDown(this);
} }
} }

View File

@@ -249,17 +249,7 @@ public class BuilderChain {
} }
var blockEntry = new BlockEntry(startPos); var blockEntry = new BlockEntry(startPos);
//Place upside-down stairs if we aim high at block
var hitVec = lookingAt.getLocation();
//Format hitvec to 0.x
hitVec = new Vec3(Math.abs(hitVec.x - ((int) hitVec.x)), Math.abs(hitVec.y - ((int) hitVec.y)), Math.abs(hitVec.z - ((int) hitVec.z)));
if (hitVec.y > 0.5) {
blockEntry.mirrorY = true;
}
startPosForPlacing = blockEntry; startPosForPlacing = blockEntry;
return blockEntry; return blockEntry;
} }

View File

@@ -45,6 +45,7 @@ public class BlockEntry {
//TODO mirror and rotate relativeHitVec? //TODO mirror and rotate relativeHitVec?
var blockPlaceContext = new MyPlaceContext(world, blockPos, direction, itemStack, clickedFace, relativeHitVec); var blockPlaceContext = new MyPlaceContext(world, blockPos, direction, itemStack, clickedFace, relativeHitVec);
newBlockState = block.getStateForPlacement(blockPlaceContext); newBlockState = block.getStateForPlacement(blockPlaceContext);
applyMirrorToBlockState();
} }
private Direction applyMirror(Direction direction) { private Direction applyMirror(Direction direction) {
@@ -54,6 +55,10 @@ public class BlockEntry {
return direction; return direction;
} }
private void applyMirrorToBlockState() {
if (mirrorY) newBlockState = BlockUtilities.getVerticalMirror(newBlockState);
}
public static void encode(FriendlyByteBuf buf, BlockEntry block) { public static void encode(FriendlyByteBuf buf, BlockEntry block) {
buf.writeBlockPos(block.blockPos); buf.writeBlockPos(block.blockPos);
buf.writeNullable(block.newBlockState, (buffer, blockState) -> buffer.writeNbt(NbtUtils.writeBlockState(blockState))); buf.writeNullable(block.newBlockState, (buffer, blockState) -> buffer.writeNbt(NbtUtils.writeBlockState(blockState)));

View File

@@ -24,14 +24,6 @@ public class MyPlaceContext extends BlockPlaceContext {
return this.getHitResult().getBlockPos(); return this.getHitResult().getBlockPos();
} }
public boolean canPlace() {
return this.getLevel().getBlockState(this.getHitResult().getBlockPos()).canBeReplaced(this);
}
public boolean replacingClickedOnBlock() {
return this.canPlace();
}
public Direction getNearestLookingDirection() { public Direction getNearestLookingDirection() {
return Direction.DOWN; return Direction.DOWN;
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 309 B