Fixed several issues. Mirroring vertically.
Modifier panel up/down buttons updating. Updating neighbouring blocks when placing blocks. Removed separate icon files.
@@ -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) {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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)));
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 273 B |
|
Before Width: | Height: | Size: 232 B |
|
Before Width: | Height: | Size: 222 B |
|
Before Width: | Height: | Size: 361 B |
|
Before Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 292 B |
|
Before Width: | Height: | Size: 370 B |
|
Before Width: | Height: | Size: 264 B |
|
Before Width: | Height: | Size: 333 B |
|
Before Width: | Height: | Size: 361 B |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 331 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 246 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 361 B |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 317 B |
|
Before Width: | Height: | Size: 310 B |
|
Before Width: | Height: | Size: 361 B |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 309 B |