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) {
placeRailWithoutUpdate(world, state, target);
} else {
world.setBlock(target, state, 18);
world.setBlock(target, state, 2); //Changed flag from 18 to 3
}
if (data != null) {

View File

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

View File

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

View File

@@ -45,6 +45,7 @@ public class BlockEntry {
//TODO mirror and rotate relativeHitVec?
var blockPlaceContext = new MyPlaceContext(world, blockPos, direction, itemStack, clickedFace, relativeHitVec);
newBlockState = block.getStateForPlacement(blockPlaceContext);
applyMirrorToBlockState();
}
private Direction applyMirror(Direction direction) {
@@ -53,6 +54,10 @@ public class BlockEntry {
if (mirrorZ && direction.getAxis() == Direction.Axis.Z) direction = direction.getOpposite();
return direction;
}
private void applyMirrorToBlockState() {
if (mirrorY) newBlockState = BlockUtilities.getVerticalMirror(newBlockState);
}
public static void encode(FriendlyByteBuf buf, BlockEntry block) {
buf.writeBlockPos(block.blockPos);

View File

@@ -24,14 +24,6 @@ public class MyPlaceContext extends BlockPlaceContext {
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() {
return Direction.DOWN;
}