Radial mirror GUI, and saving modifiers.
Saving modifiers in player persistent data on serverside, and loading when new player joins. This is separate per world. Modifier GUI panels are a bit larger now, and position fields are wider.
This commit is contained in:
@@ -11,9 +11,9 @@ import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement
|
|||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||||
|
|
||||||
public enum AllGuiTextures implements ScreenElement {
|
public enum AllGuiTextures implements ScreenElement {
|
||||||
ARRAY_ENTRY("modifiers", 226, 60),
|
ARRAY_ENTRY("modifiers", 226, 64),
|
||||||
MIRROR_ENTRY("modifiers", 0, 60, 226, 60),
|
MIRROR_ENTRY("modifiers", 0, 64, 226, 64),
|
||||||
RADIAL_MIRROR_ENTRY("modifiers", 0, 120, 226, 60),
|
RADIAL_MIRROR_ENTRY("modifiers", 0, 128, 226, 64),
|
||||||
ENABLE_BUTTON_BACKGROUND("modifiers", 234, 0, 9, 9),
|
ENABLE_BUTTON_BACKGROUND("modifiers", 234, 0, 9, 9),
|
||||||
CHECKMARK("modifiers", 243, 0, 10, 9),
|
CHECKMARK("modifiers", 243, 0, 10, 9),
|
||||||
ARROW_UP("modifiers", 234, 9, 9, 9),
|
ARROW_UP("modifiers", 234, 9, 9, 9),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package nl.requios.effortlessbuilding;
|
package nl.requios.effortlessbuilding;
|
||||||
|
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@@ -15,6 +16,9 @@ import net.minecraftforge.event.level.BlockEvent;
|
|||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
|
import nl.requios.effortlessbuilding.network.ModifierSettingsPacket;
|
||||||
|
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||||
import nl.requios.effortlessbuilding.systems.UndoRedo;
|
import nl.requios.effortlessbuilding.systems.UndoRedo;
|
||||||
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
||||||
import nl.requios.effortlessbuilding.systems.ServerBuildState;
|
import nl.requios.effortlessbuilding.systems.ServerBuildState;
|
||||||
@@ -83,12 +87,11 @@ public class CommonEvents {
|
|||||||
public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
||||||
if (event.getEntity() instanceof FakePlayer) return;
|
if (event.getEntity() instanceof FakePlayer) return;
|
||||||
Player player = event.getEntity();
|
Player player = event.getEntity();
|
||||||
if (player.getCommandSenderWorld().isClientSide) {
|
if (player.getCommandSenderWorld().isClientSide) return;
|
||||||
EffortlessBuilding.log("PlayerLoggedInEvent triggers on client side");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ServerBuildState.handleNewPlayer(player);
|
ServerBuildState.handleNewPlayer(player);
|
||||||
|
|
||||||
|
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new ModifierSettingsPacket(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmodifier;
|
package nl.requios.effortlessbuilding.buildmodifier;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.NBTHelper;
|
import nl.requios.effortlessbuilding.create.foundation.utility.NBTHelper;
|
||||||
|
import nl.requios.effortlessbuilding.network.ModifierSettingsPacket;
|
||||||
|
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -69,23 +73,29 @@ public class BuildModifiers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String DATA_KEY = EffortlessBuilding.MODID + ":buildModifiers";
|
public CompoundTag serializeNBT() {
|
||||||
|
var compoundTag = new CompoundTag();
|
||||||
public void save(Player player) {
|
compoundTag.put("modifierSettingsList", NBTHelper.writeCompoundList(modifierSettingsList, BaseModifier::serializeNBT));
|
||||||
var listTag = NBTHelper.writeCompoundList(modifierSettingsList, BaseModifier::serializeNBT);
|
return compoundTag;
|
||||||
player.getPersistentData().put(DATA_KEY, listTag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO call load
|
public void deserializeNBT(CompoundTag compoundTag) {
|
||||||
public void load(Player player) {
|
var listTag = compoundTag.getList("modifierSettingsList", Tag.TAG_COMPOUND);
|
||||||
var listTag = player.getPersistentData().getList(DATA_KEY, Tag.TAG_COMPOUND);
|
modifierSettingsList = NBTHelper.readCompoundList(listTag, tag -> {
|
||||||
modifierSettingsList = NBTHelper.readCompoundList(listTag, compoundTag -> {
|
var modifier = createModifier(tag.getString("type"));
|
||||||
var modifier = createModifier(compoundTag.getString("type"));
|
modifier.deserializeNBT(tag);
|
||||||
modifier.deserializeNBT(compoundTag);
|
|
||||||
return modifier;
|
return modifier;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
PacketHandler.INSTANCE.sendToServer(new ModifierSettingsPacket(serializeNBT()));
|
||||||
|
|
||||||
|
//Save locally as well?
|
||||||
|
// var listTag = NBTHelper.writeCompoundList(modifierSettingsList, BaseModifier::serializeNBT);
|
||||||
|
// player.getPersistentData().put(DATA_KEY, listTag);
|
||||||
|
}
|
||||||
|
|
||||||
private BaseModifier createModifier(String type) {
|
private BaseModifier createModifier(String type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "Mirror": return new Mirror();
|
case "Mirror": return new Mirror();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package nl.requios.effortlessbuilding.buildmodifier;
|
package nl.requios.effortlessbuilding.buildmodifier;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
@@ -28,6 +29,13 @@ public class RadialMirror extends BaseModifier {
|
|||||||
public boolean drawLines = true;
|
public boolean drawLines = true;
|
||||||
public boolean drawPlanes = false;
|
public boolean drawPlanes = false;
|
||||||
|
|
||||||
|
public RadialMirror() {
|
||||||
|
super();
|
||||||
|
var player = Minecraft.getInstance().player;
|
||||||
|
if (player != null)
|
||||||
|
position = Vec3.atLowerCornerOf(Minecraft.getInstance().player.blockPosition());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void findCoordinates(BlockSet blocks, Player player) {
|
public void findCoordinates(BlockSet blocks, Player player) {
|
||||||
if (!enabled) return;
|
if (!enabled) return;
|
||||||
|
|||||||
@@ -64,19 +64,19 @@ public class ArrayEntry extends BaseModifierEntry<Array> {
|
|||||||
|
|
||||||
//draw offset inputs
|
//draw offset inputs
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
offsetInputs.get(i).x = left + 47 + 20 * i;
|
offsetInputs.get(i).x = left + 49 + 20 * i;
|
||||||
offsetInputs.get(i).y = top + 18;
|
offsetInputs.get(i).y = top + 19;
|
||||||
offsetInputs.get(i).render(ms, mouseX, mouseY, partialTicks);
|
offsetInputs.get(i).render(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw count input
|
//draw count input
|
||||||
countInput.x = left + 47;
|
countInput.x = left + 49;
|
||||||
countInput.y = top + 38;
|
countInput.y = top + 41;
|
||||||
countInput.render(ms, mouseX, mouseY, partialTicks);
|
countInput.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
//draw reach label
|
//draw reach label
|
||||||
reachLabel.x = right - 8 - getFont().width(reachLabel.text);
|
reachLabel.x = right - 8 - getFont().width(reachLabel.text);
|
||||||
reachLabel.y = top + 23;
|
reachLabel.y = top + 24;
|
||||||
reachLabel.render(ms, mouseX, mouseY, partialTicks);
|
reachLabel.render(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public abstract class BaseModifierEntry<T extends BaseModifier> extends Modifier
|
|||||||
enableButton.y = top + 3;
|
enableButton.y = top + 3;
|
||||||
enableButton.render(ms, mouseX, mouseY, partialTicks);
|
enableButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
if (modifier.enabled)
|
if (modifier.enabled)
|
||||||
AllGuiTextures.CHECKMARK.render(ms, left + 5, top + 1, screen);
|
AllGuiTextures.CHECKMARK.render(ms, left + 5, top + 3, screen);
|
||||||
|
|
||||||
nameLabel.x = left + 18;
|
nameLabel.x = left + 18;
|
||||||
nameLabel.y = top + 4;
|
nameLabel.y = top + 4;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class MirrorEntry extends BaseModifierEntry<Mirror> {
|
|||||||
//ScrollInput works with double the value, so we can have 0.5 increments
|
//ScrollInput works with double the value, so we can have 0.5 increments
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
final int index = i;
|
final int index = i;
|
||||||
var scrollInput = new LabeledScrollInput(0, 0, 27, 18)
|
var scrollInput = new LabeledScrollInput(0, 0, 36, 18)
|
||||||
.showControlScrollsSlowerTooltip()
|
.showControlScrollsSlowerTooltip()
|
||||||
.titled(Component.literal(i == 0 ? "X Position" : i == 1 ? "Y Position" : "Z Position"))
|
.titled(Component.literal(i == 0 ? "X Position" : i == 1 ? "Y Position" : "Z Position"))
|
||||||
.format(integer -> Component.literal(df.format(integer / 2.0)))
|
.format(integer -> Component.literal(df.format(integer / 2.0)))
|
||||||
@@ -139,42 +139,42 @@ public class MirrorEntry extends BaseModifierEntry<Mirror> {
|
|||||||
//draw position inputs
|
//draw position inputs
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
ScrollInput input = positionInputs.get(i);
|
ScrollInput input = positionInputs.get(i);
|
||||||
input.x = left + 47 + 29 * i;
|
input.x = left + 49 + 38 * i;
|
||||||
input.y = top + 18;
|
input.y = top + 19;
|
||||||
input.render(ms, mouseX, mouseY, partialTicks);
|
input.render(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw player position button
|
//draw player position button
|
||||||
playerPositionButton.x = left + 134;
|
playerPositionButton.x = left + 163;
|
||||||
playerPositionButton.y = top + 18;
|
playerPositionButton.y = top + 19;
|
||||||
playerPositionButton.render(ms, mouseX, mouseY, partialTicks);
|
playerPositionButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
//draw toggle offset button
|
//draw toggle offset button
|
||||||
toggleOffsetButton.x = left + 154;
|
toggleOffsetButton.x = left + 183;
|
||||||
toggleOffsetButton.y = top + 18;
|
toggleOffsetButton.y = top + 19;
|
||||||
toggleOffsetButton.render(ms, mouseX, mouseY, partialTicks);
|
toggleOffsetButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
//draw axis buttons
|
//draw axis buttons
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
IconButton button = axisButtons.get(i);
|
IconButton button = axisButtons.get(i);
|
||||||
button.x = left + 47 + 18 * i;
|
button.x = left + 49 + 18 * i;
|
||||||
button.y = top + 38;
|
button.y = top + 41;
|
||||||
button.render(ms, mouseX, mouseY, partialTicks);
|
button.render(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw radius input
|
//draw radius input
|
||||||
radiusInput.x = left + 145;
|
radiusInput.x = left + 134;
|
||||||
radiusInput.y = top + 38;
|
radiusInput.y = top + 41;
|
||||||
radiusInput.render(ms, mouseX, mouseY, partialTicks);
|
radiusInput.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
//draw show lines button
|
//draw show lines button
|
||||||
showLinesButton.x = right - 43;
|
showLinesButton.x = left + 163;
|
||||||
showLinesButton.y = top + 38;
|
showLinesButton.y = top + 41;
|
||||||
showLinesButton.render(ms, mouseX, mouseY, partialTicks);
|
showLinesButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
//draw show areas button
|
//draw show areas button
|
||||||
showAreasButton.x = right - 23;
|
showAreasButton.x = left + 183;
|
||||||
showAreasButton.y = top + 38;
|
showAreasButton.y = top + 41;
|
||||||
showAreasButton.render(ms, mouseX, mouseY, partialTicks);
|
showAreasButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,262 +229,4 @@ public class MirrorEntry extends BaseModifierEntry<Mirror> {
|
|||||||
showAreasButton.setToolTip(Components.literal("Show mirror areas"));
|
showAreasButton.setToolTip(Components.literal("Show mirror areas"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected static final ResourceLocation BUILDING_ICONS = new ResourceLocation(EffortlessBuilding.MODID, "textures/gui/building_icons.png");
|
|
||||||
//
|
|
||||||
// protected List<Button> mirrorButtonList = new ArrayList<>();
|
|
||||||
// protected List<GuiIconButton> mirrorIconButtonList = new ArrayList<>();
|
|
||||||
// protected List<GuiNumberField> mirrorNumberFieldList = new ArrayList<>();
|
|
||||||
//
|
|
||||||
// private GuiNumberField textMirrorPosX, textMirrorPosY, textMirrorPosZ, textMirrorRadius;
|
|
||||||
// private GuiCheckBoxFixed buttonMirrorEnabled, buttonMirrorX, buttonMirrorY, buttonMirrorZ;
|
|
||||||
// private GuiIconButton buttonCurrentPosition, buttonToggleOdd, buttonDrawPlanes, buttonDrawLines;
|
|
||||||
// private boolean drawPlanes, drawLines, toggleOdd;
|
|
||||||
//
|
|
||||||
// public MirrorEntry(GuiScrollPane scrollPane) {
|
|
||||||
// super(scrollPane);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void init(List<Widget> renderables) {
|
|
||||||
// super.init(renderables);
|
|
||||||
//
|
|
||||||
// int y = top - 2;
|
|
||||||
// buttonMirrorEnabled = new GuiCheckBoxFixed(left - 15 + 8, y, "", false) {
|
|
||||||
// @Override
|
|
||||||
// public void onClick(double mouseX, double mouseY) {
|
|
||||||
// super.onClick(mouseX, mouseY);
|
|
||||||
// setCollapsed(!buttonMirrorEnabled.isChecked());
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// renderables.add(buttonMirrorEnabled);
|
|
||||||
//
|
|
||||||
// y = top + 18;
|
|
||||||
// textMirrorPosX = new GuiNumberField(font, renderables, left + 58, y, 62, 18);
|
|
||||||
// textMirrorPosX.setNumber(0);
|
|
||||||
// textMirrorPosX.setTooltip(
|
|
||||||
// Arrays.asList(Component.literal("The position of the mirror."), Component.literal("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
|
||||||
// mirrorNumberFieldList.add(textMirrorPosX);
|
|
||||||
//
|
|
||||||
// textMirrorPosY = new GuiNumberField(font, renderables, left + 138, y, 62, 18);
|
|
||||||
// textMirrorPosY.setNumber(64);
|
|
||||||
// textMirrorPosY.setTooltip(Arrays.asList(Component.literal("The position of the mirror."), Component.literal("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
|
||||||
// mirrorNumberFieldList.add(textMirrorPosY);
|
|
||||||
//
|
|
||||||
// textMirrorPosZ = new GuiNumberField(font, renderables, left + 218, y, 62, 18);
|
|
||||||
// textMirrorPosZ.setNumber(0);
|
|
||||||
// textMirrorPosZ.setTooltip(Arrays.asList(Component.literal("The position of the mirror."), Component.literal("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
|
||||||
// mirrorNumberFieldList.add(textMirrorPosZ);
|
|
||||||
//
|
|
||||||
// y = top + 50;
|
|
||||||
// buttonMirrorX = new GuiCheckBoxFixed(left + 60, y, " X", true);
|
|
||||||
// mirrorButtonList.add(buttonMirrorX);
|
|
||||||
//
|
|
||||||
// buttonMirrorY = new GuiCheckBoxFixed(left + 100, y, " Y", false);
|
|
||||||
// mirrorButtonList.add(buttonMirrorY);
|
|
||||||
//
|
|
||||||
// buttonMirrorZ = new GuiCheckBoxFixed(left + 140, y, " Z", false);
|
|
||||||
// mirrorButtonList.add(buttonMirrorZ);
|
|
||||||
//
|
|
||||||
// y = top + 47;
|
|
||||||
// textMirrorRadius = new GuiNumberField(font, renderables, left + 218, y, 62, 18);
|
|
||||||
// textMirrorRadius.setNumber(50);
|
|
||||||
// //TODO change to diameter (remove /2)
|
|
||||||
// textMirrorRadius.setTooltip(Arrays.asList(Component.literal("How far the mirror reaches in any direction."),
|
|
||||||
// Component.literal("Max: ").withStyle(ChatFormatting.GRAY).append(Component.literal(String.valueOf(ReachHelper.getMaxReach(mc.player) / 2)).withStyle(ChatFormatting.GOLD)),
|
|
||||||
// Component.literal("Upgradeable in survival with reach upgrades.").withStyle(ChatFormatting.GRAY)));
|
|
||||||
// mirrorNumberFieldList.add(textMirrorRadius);
|
|
||||||
//
|
|
||||||
// y = top + 72;
|
|
||||||
// buttonCurrentPosition = new GuiIconButton(left + 5, y, 0, 0, BUILDING_ICONS, button -> {
|
|
||||||
// Vec3 pos = new Vec3(Math.floor(mc.player.getX()) + 0.5, Math.floor(mc.player.getY()) + 0.5, Math.floor(mc.player.getZ()) + 0.5);
|
|
||||||
// textMirrorPosX.setNumber(pos.x);
|
|
||||||
// textMirrorPosY.setNumber(pos.y);
|
|
||||||
// textMirrorPosZ.setNumber(pos.z);
|
|
||||||
// });
|
|
||||||
// buttonCurrentPosition.setTooltip(Component.literal("Set mirror position to current player position"));
|
|
||||||
// mirrorIconButtonList.add(buttonCurrentPosition);
|
|
||||||
//
|
|
||||||
// buttonToggleOdd = new GuiIconButton(left + 35, y, 0, 20, BUILDING_ICONS, button -> {
|
|
||||||
// toggleOdd = !toggleOdd;
|
|
||||||
// buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
|
||||||
// if (toggleOdd) {
|
|
||||||
// buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set mirror position to corner of block"), Component.literal("for even numbered builds")));
|
|
||||||
// textMirrorPosX.setNumber(textMirrorPosX.getNumber() + 0.5);
|
|
||||||
// textMirrorPosY.setNumber(textMirrorPosY.getNumber() + 0.5);
|
|
||||||
// textMirrorPosZ.setNumber(textMirrorPosZ.getNumber() + 0.5);
|
|
||||||
// } else {
|
|
||||||
// buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set mirror position to middle of block"), Component.literal("for odd numbered builds")));
|
|
||||||
// textMirrorPosX.setNumber(Math.floor(textMirrorPosX.getNumber()));
|
|
||||||
// textMirrorPosY.setNumber(Math.floor(textMirrorPosY.getNumber()));
|
|
||||||
// textMirrorPosZ.setNumber(Math.floor(textMirrorPosZ.getNumber()));
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set mirror position to middle of block"), Component.literal("for odd numbered builds")));
|
|
||||||
// mirrorIconButtonList.add(buttonToggleOdd);
|
|
||||||
//
|
|
||||||
// buttonDrawLines = new GuiIconButton(left + 65, y, 0, 40, BUILDING_ICONS, button -> {
|
|
||||||
// drawLines = !drawLines;
|
|
||||||
// buttonDrawLines.setUseAlternateIcon(drawLines);
|
|
||||||
// buttonDrawLines.setTooltip(Component.literal(drawLines ? "Hide lines" : "Show lines"));
|
|
||||||
// });
|
|
||||||
// buttonDrawLines.setTooltip(Component.literal("Show lines"));
|
|
||||||
// mirrorIconButtonList.add(buttonDrawLines);
|
|
||||||
//
|
|
||||||
// buttonDrawPlanes = new GuiIconButton(left + 95, y, 0, 60, BUILDING_ICONS, button -> {
|
|
||||||
// drawPlanes = !drawPlanes;
|
|
||||||
// buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
|
||||||
// buttonDrawPlanes.setTooltip(Component.literal(drawPlanes ? "Hide area" : "Show area"));
|
|
||||||
// });
|
|
||||||
// buttonDrawPlanes.setTooltip(Component.literal("Show area"));
|
|
||||||
// mirrorIconButtonList.add(buttonDrawPlanes);
|
|
||||||
//
|
|
||||||
// ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(mc.player);
|
|
||||||
// if (modifierSettings != null) {
|
|
||||||
// Mirror.MirrorSettings m = modifierSettings.getMirrorSettings();
|
|
||||||
// buttonMirrorEnabled.setIsChecked(m.enabled);
|
|
||||||
// textMirrorPosX.setNumber(m.position.x);
|
|
||||||
// textMirrorPosY.setNumber(m.position.y);
|
|
||||||
// textMirrorPosZ.setNumber(m.position.z);
|
|
||||||
// buttonMirrorX.setIsChecked(m.mirrorX);
|
|
||||||
// buttonMirrorY.setIsChecked(m.mirrorY);
|
|
||||||
// buttonMirrorZ.setIsChecked(m.mirrorZ);
|
|
||||||
// textMirrorRadius.setNumber(m.radius);
|
|
||||||
// drawLines = m.drawLines;
|
|
||||||
// drawPlanes = m.drawPlanes;
|
|
||||||
// buttonDrawLines.setUseAlternateIcon(drawLines);
|
|
||||||
// buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
|
||||||
// buttonDrawLines.setTooltip(Component.literal(drawLines ? "Hide lines" : "Show lines"));
|
|
||||||
// buttonDrawPlanes.setTooltip(Component.literal(drawPlanes ? "Hide area" : "Show area"));
|
|
||||||
// if (textMirrorPosX.getNumber() == Math.floor(textMirrorPosX.getNumber())) {
|
|
||||||
// toggleOdd = false;
|
|
||||||
// buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set mirror position to middle of block"), Component.literal("for odd numbered builds")));
|
|
||||||
// } else {
|
|
||||||
// toggleOdd = true;
|
|
||||||
// buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set mirror position to corner of block"), Component.literal("for even numbered builds")));
|
|
||||||
// }
|
|
||||||
// buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// renderables.addAll(mirrorButtonList);
|
|
||||||
// renderables.addAll(mirrorIconButtonList);
|
|
||||||
//
|
|
||||||
// setCollapsed(!buttonMirrorEnabled.isChecked());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void updateScreen() {
|
|
||||||
// super.updateScreen();
|
|
||||||
// mirrorNumberFieldList.forEach(GuiNumberField::update);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void drawEntry(PoseStack ms, int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY,
|
|
||||||
// boolean isSelected, float partialTicks) {
|
|
||||||
//
|
|
||||||
// int yy = y;
|
|
||||||
// int offset = 8;
|
|
||||||
//
|
|
||||||
// buttonMirrorEnabled.render(ms, mouseX, mouseY, partialTicks);
|
|
||||||
// if (buttonMirrorEnabled.isChecked()) {
|
|
||||||
// buttonMirrorEnabled.y = yy;
|
|
||||||
// font.draw(ms, "Mirror enabled", left + offset, yy + 2, 0xFFFFFF);
|
|
||||||
//
|
|
||||||
// yy = y + 18;
|
|
||||||
// font.draw(ms, "Position", left + offset, yy + 5, 0xFFFFFF);
|
|
||||||
// font.draw(ms, "X", left + 40 + offset, yy + 5, 0xFFFFFF);
|
|
||||||
// textMirrorPosX.y = yy;
|
|
||||||
// font.draw(ms, "Y", left + 120 + offset, yy + 5, 0xFFFFFF);
|
|
||||||
// textMirrorPosY.y = yy;
|
|
||||||
// font.draw(ms, "Z", left + 200 + offset, yy + 5, 0xFFFFFF);
|
|
||||||
// textMirrorPosZ.y = yy;
|
|
||||||
//
|
|
||||||
// yy = y + 50;
|
|
||||||
// font.draw(ms, "Direction", left + offset, yy + 2, 0xFFFFFF);
|
|
||||||
// buttonMirrorX.y = yy;
|
|
||||||
// buttonMirrorY.y = yy;
|
|
||||||
// buttonMirrorZ.y = yy;
|
|
||||||
// font.draw(ms, "Radius", left + 176 + offset, yy + 2, 0xFFFFFF);
|
|
||||||
// textMirrorRadius.y = yy - 3;
|
|
||||||
//
|
|
||||||
// yy = y + 72;
|
|
||||||
// buttonCurrentPosition.y = yy;
|
|
||||||
// buttonToggleOdd.y = yy;
|
|
||||||
// buttonDrawLines.y = yy;
|
|
||||||
// buttonDrawPlanes.y = yy;
|
|
||||||
//
|
|
||||||
// mirrorButtonList.forEach(button -> button.render(ms, mouseX, mouseY, partialTicks));
|
|
||||||
// mirrorIconButtonList.forEach(button -> button.render(ms, mouseX, mouseY, partialTicks));
|
|
||||||
// mirrorNumberFieldList.forEach(numberField -> numberField.drawNumberField(ms, mouseX, mouseY, partialTicks));
|
|
||||||
// } else {
|
|
||||||
// buttonMirrorEnabled.y = yy;
|
|
||||||
// font.draw(ms, "Mirror disabled", left + offset, yy + 2, 0x999999);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void drawTooltip(PoseStack ms, Screen guiScreen, int mouseX, int mouseY) {
|
|
||||||
// //Draw tooltips last
|
|
||||||
// if (buttonMirrorEnabled.isChecked()) {
|
|
||||||
// mirrorIconButtonList.forEach(iconButton -> iconButton.drawTooltip(ms, scrollPane.parent, mouseX, mouseY));
|
|
||||||
// mirrorNumberFieldList.forEach(numberField -> numberField.drawTooltip(ms, scrollPane.parent, mouseX, mouseY));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean charTyped(char typedChar, int modifiers) {
|
|
||||||
// super.charTyped(typedChar, modifiers);
|
|
||||||
// for (GuiNumberField numberField : mirrorNumberFieldList) {
|
|
||||||
// numberField.charTyped(typedChar, modifiers);
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY) {
|
|
||||||
// mirrorNumberFieldList.forEach(numberField -> numberField.mouseClicked(mouseX, mouseY, mouseEvent));
|
|
||||||
//
|
|
||||||
// boolean insideMirrorEnabledLabel = mouseX >= left && mouseX < right && relativeY >= -2 && relativeY < 12;
|
|
||||||
//
|
|
||||||
// if (insideMirrorEnabledLabel) {
|
|
||||||
// buttonMirrorEnabled.playDownSound(this.mc.getSoundManager());
|
|
||||||
// buttonMirrorEnabled.onClick(mouseX, mouseY);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public Mirror.MirrorSettings getMirrorSettings() {
|
|
||||||
// boolean mirrorEnabled = buttonMirrorEnabled.isChecked();
|
|
||||||
//
|
|
||||||
// Vec3 mirrorPos = new Vec3(0, 64, 0);
|
|
||||||
// try {
|
|
||||||
// mirrorPos = new Vec3(textMirrorPosX.getNumber(), textMirrorPosY.getNumber(), textMirrorPosZ.getNumber());
|
|
||||||
// } catch (NumberFormatException | NullPointerException ex) {
|
|
||||||
// EffortlessBuilding.log(mc.player, "Mirror position not a valid number.");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// boolean mirrorX = buttonMirrorX.isChecked();
|
|
||||||
// boolean mirrorY = buttonMirrorY.isChecked();
|
|
||||||
// boolean mirrorZ = buttonMirrorZ.isChecked();
|
|
||||||
//
|
|
||||||
// int mirrorRadius = 50;
|
|
||||||
// try {
|
|
||||||
// mirrorRadius = (int) textMirrorRadius.getNumber();
|
|
||||||
// } catch (NumberFormatException | NullPointerException ex) {
|
|
||||||
// EffortlessBuilding.log(mc.player, "Mirror radius not a valid number.");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return new Mirror.MirrorSettings(mirrorEnabled, mirrorPos, mirrorX, mirrorY, mirrorZ, mirrorRadius, drawLines, drawPlanes);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected String getName() {
|
|
||||||
// return "Mirror";
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected int getExpandedHeight() {
|
|
||||||
// return 100;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class ModifiersScreen extends AbstractSimiScreen {
|
|||||||
int listL = this.width / 2 - listWidth / 2;
|
int listL = this.width / 2 - listWidth / 2;
|
||||||
int listR = this.width / 2 + listWidth / 2;
|
int listR = this.width / 2 + listWidth / 2;
|
||||||
|
|
||||||
list = new ModifiersScreenList(minecraft, listWidth, height - 80, 45, height - 45, 65);
|
list = new ModifiersScreenList(minecraft, listWidth, height - 80, 45, height - 45, 68);
|
||||||
list.setLeftPos(this.width / 2 - list.getWidth() / 2);
|
list.setLeftPos(this.width / 2 - list.getWidth() / 2);
|
||||||
|
|
||||||
addRenderableWidget(list);
|
addRenderableWidget(list);
|
||||||
@@ -159,7 +159,7 @@ public class ModifiersScreen extends AbstractSimiScreen {
|
|||||||
@Override
|
@Override
|
||||||
public void onClose() {
|
public void onClose() {
|
||||||
super.onClose();
|
super.onClose();
|
||||||
EffortlessBuildingClient.BUILD_MODIFIERS.save(minecraft.player);
|
EffortlessBuildingClient.BUILD_MODIFIERS.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,295 +1,239 @@
|
|||||||
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.gui.components.Widget;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
|
||||||
import net.minecraft.client.gui.components.Button;
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraft.ChatFormatting;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import nl.requios.effortlessbuilding.AllGuiTextures;
|
import nl.requios.effortlessbuilding.AllGuiTextures;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.AllIcons;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.RadialMirror;
|
import nl.requios.effortlessbuilding.buildmodifier.RadialMirror;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.gui.AbstractSimiScreen;
|
import nl.requios.effortlessbuilding.create.foundation.gui.widget.IconButton;
|
||||||
import nl.requios.effortlessbuilding.gui.elements.*;
|
import nl.requios.effortlessbuilding.create.foundation.gui.widget.ScrollInput;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||||
|
import nl.requios.effortlessbuilding.gui.elements.LabeledScrollInput;
|
||||||
|
import nl.requios.effortlessbuilding.utilities.MathHelper;
|
||||||
import nl.requios.effortlessbuilding.utilities.ReachHelper;
|
import nl.requios.effortlessbuilding.utilities.ReachHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.text.DecimalFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Vector;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@SuppressWarnings("Duplicates")
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public class RadialMirrorEntry extends BaseModifierEntry<RadialMirror> {
|
public class RadialMirrorEntry extends BaseModifierEntry<RadialMirror> {
|
||||||
|
|
||||||
public RadialMirrorEntry(ModifiersScreen screen, BaseModifier modifier) {
|
protected Vector<ScrollInput> positionInputs;
|
||||||
super(screen, (RadialMirror) modifier, Component.literal("Radial Mirror"), AllGuiTextures.RADIAL_MIRROR_ENTRY);
|
protected IconButton playerPositionButton;
|
||||||
|
protected IconButton toggleOffsetButton;
|
||||||
|
protected ScrollInput slicesInput;
|
||||||
|
protected IconButton alternateButton;
|
||||||
|
protected ScrollInput radiusInput;
|
||||||
|
protected IconButton showLinesButton;
|
||||||
|
protected IconButton showAreasButton;
|
||||||
|
protected DecimalFormat df = new DecimalFormat("#.#");
|
||||||
|
|
||||||
|
public RadialMirrorEntry(ModifiersScreen screen, BaseModifier radialMirror) {
|
||||||
|
super(screen, (RadialMirror) radialMirror, Component.literal("Radial Mirror"), AllGuiTextures.RADIAL_MIRROR_ENTRY);
|
||||||
|
|
||||||
|
positionInputs = new Vector<>();
|
||||||
|
|
||||||
|
//Position
|
||||||
|
//ScrollInput works with double the value, so we can have 0.5 increments
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
final int index = i;
|
||||||
|
var scrollInput = new LabeledScrollInput(0, 0, 36, 18)
|
||||||
|
.showControlScrollsSlowerTooltip()
|
||||||
|
.titled(Component.literal(i == 0 ? "X Position" : i == 1 ? "Y Position" : "Z Position"))
|
||||||
|
.format(integer -> Component.literal(df.format(integer / 2.0)))
|
||||||
|
.withStepFunction(stepContext -> stepContext.shift ? 20 : stepContext.control ? 1 : 2)
|
||||||
|
.calling(value -> {
|
||||||
|
modifier.position = MathHelper.with(modifier.position, index, value / 2.0);
|
||||||
|
onValueChanged();
|
||||||
|
});
|
||||||
|
scrollInput.setState((int) (MathHelper.get(modifier.position, index) * 2.0));
|
||||||
|
positionInputs.add(scrollInput);
|
||||||
|
}
|
||||||
|
listeners.addAll(positionInputs);
|
||||||
|
|
||||||
|
//Player position button
|
||||||
|
playerPositionButton = new IconButton(0, 0, AllIcons.I_PLAYER)
|
||||||
|
.withCallback(() -> {
|
||||||
|
modifier.position = Vec3.atLowerCornerOf(Minecraft.getInstance().player.blockPosition());
|
||||||
|
onValueChanged();
|
||||||
|
});
|
||||||
|
playerPositionButton.setToolTip(Components.literal("Set to player position"));
|
||||||
|
listeners.add(playerPositionButton);
|
||||||
|
|
||||||
|
//Toggle offset button
|
||||||
|
toggleOffsetButton = new IconButton(0, 0, AllIcons.I_BLOCK_CENTER)
|
||||||
|
.withCallback(() -> {
|
||||||
|
if (modifier.position.x == Math.floor(modifier.position.x)) {
|
||||||
|
modifier.position = new Vec3(
|
||||||
|
Math.floor(modifier.position.x) + 0.5,
|
||||||
|
Math.floor(modifier.position.y) + 0.5,
|
||||||
|
Math.floor(modifier.position.z) + 0.5
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
modifier.position = new Vec3(
|
||||||
|
Math.floor(modifier.position.x),
|
||||||
|
Math.floor(modifier.position.y),
|
||||||
|
Math.floor(modifier.position.z)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
onValueChanged();
|
||||||
|
});
|
||||||
|
listeners.add(toggleOffsetButton);
|
||||||
|
|
||||||
|
//Slices
|
||||||
|
slicesInput = new LabeledScrollInput(0, 0, 27, 18)
|
||||||
|
.withRange(3, 1000)
|
||||||
|
.titled(Component.literal("Slices"))
|
||||||
|
.calling(value -> {
|
||||||
|
modifier.slices = value;
|
||||||
|
onValueChanged();
|
||||||
|
});
|
||||||
|
slicesInput.setState(modifier.slices);
|
||||||
|
listeners.add(slicesInput);
|
||||||
|
|
||||||
|
//Alternate
|
||||||
|
alternateButton = new IconButton(0, 0, AllIcons.I_SHOW_AREAS)
|
||||||
|
.withCallback(() -> {
|
||||||
|
modifier.alternate = !modifier.alternate;
|
||||||
|
onValueChanged();
|
||||||
|
});
|
||||||
|
listeners.add(alternateButton);
|
||||||
|
|
||||||
|
//Radius
|
||||||
|
radiusInput = new LabeledScrollInput(0, 0, 27, 18)
|
||||||
|
.withRange(0, ReachHelper.getMaxMirrorRadius(Minecraft.getInstance().player))
|
||||||
|
.titled(Component.literal("Radius. Use Reach Upgrade items to increase maximum."))
|
||||||
|
.calling(value -> {
|
||||||
|
modifier.radius = value;
|
||||||
|
onValueChanged();
|
||||||
|
});
|
||||||
|
radiusInput.setState(modifier.radius);
|
||||||
|
listeners.add(radiusInput);
|
||||||
|
|
||||||
|
//Show lines button
|
||||||
|
showLinesButton = new IconButton(0, 0, AllIcons.I_SHOW_LINES)
|
||||||
|
.withCallback(() -> {
|
||||||
|
modifier.drawLines = !modifier.drawLines;
|
||||||
|
onValueChanged();
|
||||||
|
});
|
||||||
|
listeners.add(showLinesButton);
|
||||||
|
|
||||||
|
//Show areas button
|
||||||
|
showAreasButton = new IconButton(0, 0, AllIcons.I_SHOW_AREAS)
|
||||||
|
.withCallback(() -> {
|
||||||
|
modifier.drawPlanes = !modifier.drawPlanes;
|
||||||
|
onValueChanged();
|
||||||
|
});
|
||||||
|
listeners.add(showAreasButton);
|
||||||
|
|
||||||
|
for (ScrollInput positionInput : positionInputs) {
|
||||||
|
positionInput.onChanged();
|
||||||
|
}
|
||||||
|
radiusInput.onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected static final ResourceLocation BUILDING_ICONS = new ResourceLocation(EffortlessBuilding.MODID, "textures/gui/building_icons.png");
|
@Override
|
||||||
//
|
public void render(PoseStack ms, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean p_230432_9_, float partialTicks) {
|
||||||
// protected List<Button> radialMirrorButtonList = new ArrayList<>();
|
super.render(ms, index, y, x, width, height, mouseX, mouseY, p_230432_9_, partialTicks);
|
||||||
// protected List<GuiIconButton> radialMirrorIconButtonList = new ArrayList<>();
|
|
||||||
// protected List<GuiNumberField> radialMirrorNumberFieldList = new ArrayList<>();
|
//draw position inputs
|
||||||
//
|
for (int i = 0; i < 3; i++) {
|
||||||
// private GuiNumberField textRadialMirrorPosX, textRadialMirrorPosY, textRadialMirrorPosZ, textRadialMirrorSlices, textRadialMirrorRadius;
|
ScrollInput input = positionInputs.get(i);
|
||||||
// private GuiCheckBoxFixed buttonRadialMirrorEnabled, buttonRadialMirrorAlternate;
|
input.x = left + 49 + 38 * i;
|
||||||
// private GuiIconButton buttonCurrentPosition, buttonToggleOdd, buttonDrawPlanes, buttonDrawLines;
|
input.y = top + 19;
|
||||||
// private boolean drawPlanes, drawLines, toggleOdd;
|
input.render(ms, mouseX, mouseY, partialTicks);
|
||||||
//
|
}
|
||||||
// public RadialMirrorEntry(GuiScrollPane scrollPane) {
|
|
||||||
// super(scrollPane);
|
//draw player position button
|
||||||
// }
|
playerPositionButton.x = left + 163;
|
||||||
//
|
playerPositionButton.y = top + 19;
|
||||||
// @Override
|
playerPositionButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
// public void init(List<Widget> renderables) {
|
|
||||||
// super.init(renderables);
|
//draw toggle offset button
|
||||||
//
|
toggleOffsetButton.x = left + 183;
|
||||||
// int y = top - 2;
|
toggleOffsetButton.y = top + 19;
|
||||||
// buttonRadialMirrorEnabled = new GuiCheckBoxFixed(left - 15 + 8, y, "", false) {
|
toggleOffsetButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
// @Override
|
|
||||||
// public void onClick(double mouseX, double mouseY) {
|
//draw slices input
|
||||||
// super.onClick(mouseX, mouseY);
|
slicesInput.x = left + 49;
|
||||||
// setCollapsed(!buttonRadialMirrorEnabled.isChecked());
|
slicesInput.y = top + 41;
|
||||||
// }
|
slicesInput.render(ms, mouseX, mouseY, partialTicks);
|
||||||
// };
|
|
||||||
// renderables.add(buttonRadialMirrorEnabled);
|
//draw alternate button
|
||||||
//
|
alternateButton.x = left + 78;
|
||||||
// y = top + 18;
|
alternateButton.y = top + 41;
|
||||||
// textRadialMirrorPosX = new GuiNumberField(font, renderables, left + 58, y, 62, 18);
|
alternateButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
// textRadialMirrorPosX.setNumber(0);
|
|
||||||
// textRadialMirrorPosX.setTooltip(
|
//draw radius input
|
||||||
// Arrays.asList(Component.literal("The position of the radial mirror."), Component.literal("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
radiusInput.x = left + 134;
|
||||||
// radialMirrorNumberFieldList.add(textRadialMirrorPosX);
|
radiusInput.y = top + 41;
|
||||||
//
|
radiusInput.render(ms, mouseX, mouseY, partialTicks);
|
||||||
// textRadialMirrorPosY = new GuiNumberField(font, renderables, left + 138, y, 62, 18);
|
|
||||||
// textRadialMirrorPosY.setNumber(64);
|
//draw show lines button
|
||||||
// textRadialMirrorPosY.setTooltip(Arrays.asList(Component.literal("The position of the radial mirror."), Component.literal("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
showLinesButton.x = left + 163;
|
||||||
// radialMirrorNumberFieldList.add(textRadialMirrorPosY);
|
showLinesButton.y = top + 41;
|
||||||
//
|
showLinesButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
// textRadialMirrorPosZ = new GuiNumberField(font, renderables, left + 218, y, 62, 18);
|
|
||||||
// textRadialMirrorPosZ.setNumber(0);
|
//draw show areas button
|
||||||
// textRadialMirrorPosZ.setTooltip(Arrays.asList(Component.literal("The position of the radial mirror."), Component.literal("For odd numbered builds add 0.5.").withStyle(ChatFormatting.GRAY)));
|
showAreasButton.x = left + 183;
|
||||||
// radialMirrorNumberFieldList.add(textRadialMirrorPosZ);
|
showAreasButton.y = top + 41;
|
||||||
//
|
showAreasButton.render(ms, mouseX, mouseY, partialTicks);
|
||||||
// y = top + 47;
|
}
|
||||||
// textRadialMirrorSlices = new GuiNumberField(font, renderables, left + 55, y, 50, 18);
|
|
||||||
// textRadialMirrorSlices.setNumber(4);
|
@Override
|
||||||
// textRadialMirrorSlices.setTooltip(Arrays.asList(Component.literal("The number of repeating slices."), Component.literal("Minimally 2.").withStyle(ChatFormatting.GRAY)));
|
public void onValueChanged() {
|
||||||
// radialMirrorNumberFieldList.add(textRadialMirrorSlices);
|
super.onValueChanged();
|
||||||
//
|
|
||||||
// textRadialMirrorRadius = new GuiNumberField(font, renderables, left + 218, y, 62, 18);
|
//Position
|
||||||
// textRadialMirrorRadius.setNumber(50);
|
for (int i = 0; i < 3; i++) {
|
||||||
// //TODO change to diameter (remove /2)
|
ScrollInput input = positionInputs.get(i);
|
||||||
// textRadialMirrorRadius.setTooltip(Arrays.asList(Component.literal("How far the radial mirror reaches from its center position."),
|
input.setState((int) (MathHelper.get(modifier.position, i) * 2.0));
|
||||||
// Component.literal("Max: ").withStyle(ChatFormatting.GRAY).append(Component.literal(String.valueOf(ReachHelper.getMaxReach(mc.player) / 2)).withStyle(ChatFormatting.GOLD)),
|
}
|
||||||
// Component.literal("Upgradeable in survival with reach upgrades.").withStyle(ChatFormatting.GRAY)));
|
|
||||||
// radialMirrorNumberFieldList.add(textRadialMirrorRadius);
|
//Toggle offset button
|
||||||
//
|
if (modifier.position.x == Math.floor(modifier.position.x)) {
|
||||||
// y = top + 72;
|
toggleOffsetButton.setIcon(AllIcons.I_BLOCK_CENTER);
|
||||||
// buttonCurrentPosition = new GuiIconButton(left + 5, y, 0, 0, BUILDING_ICONS, button -> {
|
toggleOffsetButton.setToolTip(Components.literal("Set radialMirror position to center of block, for uneven numbered builds."));
|
||||||
// Vec3 pos = new Vec3(Math.floor(mc.player.getX()) + 0.5, Math.floor(mc.player.getY()) + 0.5, Math.floor(mc.player.getZ()) + 0.5);
|
}
|
||||||
// textRadialMirrorPosX.setNumber(pos.x);
|
else {
|
||||||
// textRadialMirrorPosY.setNumber(pos.y);
|
toggleOffsetButton.setIcon(AllIcons.I_BLOCK_CORNER);
|
||||||
// textRadialMirrorPosZ.setNumber(pos.z);
|
toggleOffsetButton.setToolTip(Components.literal("Set radialMirror position to corner of block, for even numbered builds."));
|
||||||
// });
|
}
|
||||||
// buttonCurrentPosition.setTooltip(Component.literal("Set radial mirror position to current player position"));
|
|
||||||
// radialMirrorIconButtonList.add(buttonCurrentPosition);
|
//Toggle alternate button
|
||||||
//
|
if (modifier.alternate) {
|
||||||
// buttonToggleOdd = new GuiIconButton(left + 35, y, 0, 20, BUILDING_ICONS, button -> {
|
alternateButton.setIcon(AllIcons.I_SHOW_AREAS);
|
||||||
// toggleOdd = !toggleOdd;
|
alternateButton.setToolTip(Components.literal("Alternate the direction of every other slice: Currently ON"));
|
||||||
// buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
}
|
||||||
// if (toggleOdd) {
|
else {
|
||||||
// buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set mirror position to corner of block"), Component.literal("for even numbered builds")));
|
alternateButton.setIcon(AllIcons.I_HIDE_AREAS);
|
||||||
// textRadialMirrorPosX.setNumber(textRadialMirrorPosX.getNumber() + 0.5);
|
alternateButton.setToolTip(Components.literal("Alternate the direction of every other slice. Currently OFF"));
|
||||||
// textRadialMirrorPosY.setNumber(textRadialMirrorPosY.getNumber() + 0.5);
|
}
|
||||||
// textRadialMirrorPosZ.setNumber(textRadialMirrorPosZ.getNumber() + 0.5);
|
|
||||||
// } else {
|
//Show lines button
|
||||||
// buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set mirror position to middle of block"), Component.literal("for odd numbered builds")));
|
if (modifier.drawLines) {
|
||||||
// textRadialMirrorPosX.setNumber(Math.floor(textRadialMirrorPosX.getNumber()));
|
showLinesButton.setIcon(AllIcons.I_SHOW_LINES);
|
||||||
// textRadialMirrorPosY.setNumber(Math.floor(textRadialMirrorPosY.getNumber()));
|
showLinesButton.setToolTip(Components.literal("Hide radial mirror lines"));
|
||||||
// textRadialMirrorPosZ.setNumber(Math.floor(textRadialMirrorPosZ.getNumber()));
|
}
|
||||||
// }
|
else {
|
||||||
// });
|
showLinesButton.setIcon(AllIcons.I_HIDE_LINES);
|
||||||
// buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set radial mirror position to middle of block"), Component.literal("for odd numbered builds")));
|
showLinesButton.setToolTip(Components.literal("Show radial mirror lines"));
|
||||||
// radialMirrorIconButtonList.add(buttonToggleOdd);
|
}
|
||||||
//
|
|
||||||
// buttonDrawLines = new GuiIconButton(left + 65, y, 0, 40, BUILDING_ICONS, button -> {
|
//Show areas button
|
||||||
// drawLines = !drawLines;
|
if (modifier.drawPlanes) {
|
||||||
// buttonDrawLines.setUseAlternateIcon(drawLines);
|
showAreasButton.setIcon(AllIcons.I_SHOW_AREAS);
|
||||||
// buttonDrawLines.setTooltip(Component.literal(drawLines ? "Hide lines" : "Show lines"));
|
showAreasButton.setToolTip(Components.literal("Hide radial mirror areas"));
|
||||||
// });
|
}
|
||||||
// buttonDrawLines.setTooltip(Component.literal("Show lines"));
|
else {
|
||||||
// radialMirrorIconButtonList.add(buttonDrawLines);
|
showAreasButton.setIcon(AllIcons.I_HIDE_AREAS);
|
||||||
//
|
showAreasButton.setToolTip(Components.literal("Show radial mirror areas"));
|
||||||
// buttonDrawPlanes = new GuiIconButton(left + 95, y, 0, 60, BUILDING_ICONS, button -> {
|
}
|
||||||
// drawPlanes = !drawPlanes;
|
}
|
||||||
// buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
|
||||||
// buttonDrawPlanes.setTooltip(Component.literal(drawPlanes ? "Hide area" : "Show area"));
|
|
||||||
// });
|
|
||||||
// buttonDrawPlanes.setTooltip(Component.literal("Show area"));
|
|
||||||
// radialMirrorIconButtonList.add(buttonDrawPlanes);
|
|
||||||
//
|
|
||||||
// y = top + 76;
|
|
||||||
// buttonRadialMirrorAlternate = new GuiCheckBoxFixed(left + 140, y, " Alternate", false);
|
|
||||||
// radialMirrorButtonList.add(buttonRadialMirrorAlternate);
|
|
||||||
//
|
|
||||||
// ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(mc.player);
|
|
||||||
// if (modifierSettings != null) {
|
|
||||||
// RadialMirror.RadialMirrorSettings r = modifierSettings.getRadialMirrorSettings();
|
|
||||||
// buttonRadialMirrorEnabled.setIsChecked(r.enabled);
|
|
||||||
// textRadialMirrorPosX.setNumber(r.position.x);
|
|
||||||
// textRadialMirrorPosY.setNumber(r.position.y);
|
|
||||||
// textRadialMirrorPosZ.setNumber(r.position.z);
|
|
||||||
// textRadialMirrorSlices.setNumber(r.slices);
|
|
||||||
// buttonRadialMirrorAlternate.setIsChecked(r.alternate);
|
|
||||||
// textRadialMirrorRadius.setNumber(r.radius);
|
|
||||||
// drawLines = r.drawLines;
|
|
||||||
// drawPlanes = r.drawPlanes;
|
|
||||||
// buttonDrawLines.setUseAlternateIcon(drawLines);
|
|
||||||
// buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
|
||||||
// buttonDrawLines.setTooltip(Component.literal(drawLines ? "Hide lines" : "Show lines"));
|
|
||||||
// buttonDrawPlanes.setTooltip(Component.literal(drawPlanes ? "Hide area" : "Show area"));
|
|
||||||
// if (textRadialMirrorPosX.getNumber() == Math.floor(textRadialMirrorPosX.getNumber())) {
|
|
||||||
// toggleOdd = false;
|
|
||||||
// buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set radial mirror position to middle of block"), Component.literal("for odd numbered builds")));
|
|
||||||
// } else {
|
|
||||||
// toggleOdd = true;
|
|
||||||
// buttonToggleOdd.setTooltip(Arrays.asList(Component.literal("Set radial mirror position to corner of block"), Component.literal("for even numbered builds")));
|
|
||||||
// }
|
|
||||||
// buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// renderables.addAll(radialMirrorButtonList);
|
|
||||||
// renderables.addAll(radialMirrorIconButtonList);
|
|
||||||
//
|
|
||||||
// setCollapsed(!buttonRadialMirrorEnabled.isChecked());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void updateScreen() {
|
|
||||||
// radialMirrorNumberFieldList.forEach(GuiNumberField::update);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void drawEntry(PoseStack ms, int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY,
|
|
||||||
// boolean isSelected, float partialTicks) {
|
|
||||||
//
|
|
||||||
// int yy = y;
|
|
||||||
// int offset = 8;
|
|
||||||
//
|
|
||||||
// buttonRadialMirrorEnabled.render(ms, mouseX, mouseY, partialTicks);
|
|
||||||
// if (buttonRadialMirrorEnabled.isChecked()) {
|
|
||||||
// buttonRadialMirrorEnabled.y = yy;
|
|
||||||
// font.draw(ms, "Radial mirror enabled", left + offset, yy + 2, 0xFFFFFF);
|
|
||||||
//
|
|
||||||
// yy = y + 18;
|
|
||||||
// font.draw(ms, "Position", left + offset, yy + 5, 0xFFFFFF);
|
|
||||||
// font.draw(ms, "X", left + 40 + offset, yy + 5, 0xFFFFFF);
|
|
||||||
// textRadialMirrorPosX.y = yy;
|
|
||||||
// font.draw(ms, "Y", left + 120 + offset, yy + 5, 0xFFFFFF);
|
|
||||||
// textRadialMirrorPosY.y = yy;
|
|
||||||
// font.draw(ms, "Z", left + 200 + offset, yy + 5, 0xFFFFFF);
|
|
||||||
// textRadialMirrorPosZ.y = yy;
|
|
||||||
//
|
|
||||||
// yy = y + 50;
|
|
||||||
// font.draw(ms, "Slices", left + offset, yy + 2, 0xFFFFFF);
|
|
||||||
// textRadialMirrorSlices.y = yy - 3;
|
|
||||||
// font.draw(ms, "Radius", left + 176 + offset, yy + 2, 0xFFFFFF);
|
|
||||||
// textRadialMirrorRadius.y = yy - 3;
|
|
||||||
//
|
|
||||||
// yy = y + 72;
|
|
||||||
// buttonCurrentPosition.y = yy;
|
|
||||||
// buttonToggleOdd.y = yy;
|
|
||||||
// buttonDrawLines.y = yy;
|
|
||||||
// buttonDrawPlanes.y = yy;
|
|
||||||
//
|
|
||||||
// yy = y + 76;
|
|
||||||
// buttonRadialMirrorAlternate.y = yy;
|
|
||||||
//
|
|
||||||
// radialMirrorButtonList.forEach(button -> button.render(ms, mouseX, mouseY, partialTicks));
|
|
||||||
// radialMirrorIconButtonList.forEach(button -> button.render(ms, mouseX, mouseY, partialTicks));
|
|
||||||
// radialMirrorNumberFieldList
|
|
||||||
// .forEach(numberField -> numberField.drawNumberField(ms, mouseX, mouseY, partialTicks));
|
|
||||||
// } else {
|
|
||||||
// buttonRadialMirrorEnabled.y = yy;
|
|
||||||
// font.draw(ms, "Radial mirror disabled", left + offset, yy + 2, 0x999999);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void drawTooltip(PoseStack ms, Screen guiScreen, int mouseX, int mouseY) {
|
|
||||||
// //Draw tooltips last
|
|
||||||
// if (buttonRadialMirrorEnabled.isChecked()) {
|
|
||||||
// radialMirrorIconButtonList.forEach(iconButton -> iconButton.drawTooltip(ms, scrollPane.parent, mouseX, mouseY));
|
|
||||||
// radialMirrorNumberFieldList.forEach(numberField -> numberField.drawTooltip(ms, scrollPane.parent, mouseX, mouseY));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean charTyped(char typedChar, int modifiers) {
|
|
||||||
// super.charTyped(typedChar, modifiers);
|
|
||||||
// for (GuiNumberField numberField : radialMirrorNumberFieldList) {
|
|
||||||
// numberField.charTyped(typedChar, modifiers);
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY) {
|
|
||||||
// radialMirrorNumberFieldList.forEach(numberField -> numberField.mouseClicked(mouseX, mouseY, mouseEvent));
|
|
||||||
//
|
|
||||||
// boolean insideRadialMirrorEnabledLabel = mouseX >= left && mouseX < right && relativeY >= -2 && relativeY < 12;
|
|
||||||
//
|
|
||||||
// if (insideRadialMirrorEnabledLabel) {
|
|
||||||
// buttonRadialMirrorEnabled.playDownSound(this.mc.getSoundManager());
|
|
||||||
// buttonRadialMirrorEnabled.onClick(mouseX, mouseY);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public RadialMirror.RadialMirrorSettings getRadialMirrorSettings() {
|
|
||||||
// boolean radialMirrorEnabled = buttonRadialMirrorEnabled.isChecked();
|
|
||||||
//
|
|
||||||
// Vec3 radialMirrorPos = new Vec3(0, 64, 0);
|
|
||||||
// try {
|
|
||||||
// radialMirrorPos = new Vec3(textRadialMirrorPosX.getNumber(), textRadialMirrorPosY.getNumber(), textRadialMirrorPosZ
|
|
||||||
// .getNumber());
|
|
||||||
// } catch (NumberFormatException | NullPointerException ex) {
|
|
||||||
// EffortlessBuilding.log(mc.player, "Radial mirror position not a valid number.");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// int radialMirrorSlices = 4;
|
|
||||||
// try {
|
|
||||||
// radialMirrorSlices = (int) textRadialMirrorSlices.getNumber();
|
|
||||||
// } catch (NumberFormatException | NullPointerException ex) {
|
|
||||||
// EffortlessBuilding.log(mc.player, "Radial mirror slices not a valid number.");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// boolean radialMirrorAlternate = buttonRadialMirrorAlternate.isChecked();
|
|
||||||
//
|
|
||||||
// int radialMirrorRadius = 50;
|
|
||||||
// try {
|
|
||||||
// radialMirrorRadius = (int) textRadialMirrorRadius.getNumber();
|
|
||||||
// } catch (NumberFormatException | NullPointerException ex) {
|
|
||||||
// EffortlessBuilding.log(mc.player, "Mirror radius not a valid number.");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return new RadialMirror.RadialMirrorSettings(radialMirrorEnabled, radialMirrorPos, radialMirrorSlices, radialMirrorAlternate, radialMirrorRadius, drawLines, drawPlanes);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected String getName() {
|
|
||||||
// return "Radial mirror";
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected int getExpandedHeight() {
|
|
||||||
// return 100;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,6 @@ import nl.requios.effortlessbuilding.systems.ServerBuildState;
|
|||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
|
||||||
* Shares mode settings (see ModeSettingsManager) between server and client
|
|
||||||
*/
|
|
||||||
public class IsQuickReplacingPacket {
|
public class IsQuickReplacingPacket {
|
||||||
private boolean isQuickReplacing;
|
private boolean isQuickReplacing;
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,6 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
import nl.requios.effortlessbuilding.systems.ServerBuildState;
|
import nl.requios.effortlessbuilding.systems.ServerBuildState;
|
||||||
|
|
||||||
/**
|
|
||||||
* Shares mode settings (see ModeSettingsManager) between server and client
|
|
||||||
*/
|
|
||||||
public class IsUsingBuildModePacket {
|
public class IsUsingBuildModePacket {
|
||||||
private boolean isUsingBuildMode;
|
private boolean isUsingBuildMode;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package nl.requios.effortlessbuilding.network;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.Tag;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
|
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||||
|
import nl.requios.effortlessbuilding.buildmodifier.Array;
|
||||||
|
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
||||||
|
import nl.requios.effortlessbuilding.buildmodifier.Mirror;
|
||||||
|
import nl.requios.effortlessbuilding.buildmodifier.RadialMirror;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.NBTHelper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sync build modifiers between server and client, for saving and loading.
|
||||||
|
*/
|
||||||
|
public class ModifierSettingsPacket {
|
||||||
|
|
||||||
|
private static final String DATA_KEY = EffortlessBuilding.MODID + ":buildModifiers";
|
||||||
|
private CompoundTag modifiersTag;
|
||||||
|
|
||||||
|
public ModifierSettingsPacket() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModifierSettingsPacket(CompoundTag modifiersTag) {
|
||||||
|
this.modifiersTag = modifiersTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Only on server
|
||||||
|
public ModifierSettingsPacket(Player player) {
|
||||||
|
this.modifiersTag = player.getPersistentData().getCompound(DATA_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void encode(ModifierSettingsPacket message, FriendlyByteBuf buf) {
|
||||||
|
buf.writeNbt(message.modifiersTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ModifierSettingsPacket decode(FriendlyByteBuf buf) {
|
||||||
|
return new ModifierSettingsPacket(buf.readNbt());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Handler {
|
||||||
|
public static void handle(ModifierSettingsPacket message, Supplier<NetworkEvent.Context> ctx) {
|
||||||
|
if (ctx.get().getDirection().getReceptionSide().isServer()) {
|
||||||
|
ctx.get().enqueueWork(() -> {
|
||||||
|
var player = ctx.get().getSender();
|
||||||
|
//Save to persistent player data
|
||||||
|
player.getPersistentData().put(DATA_KEY, message.modifiersTag);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
ctx.get().enqueueWork(() -> {
|
||||||
|
//Load from persistent player data
|
||||||
|
EffortlessBuildingClient.BUILD_MODIFIERS.deserializeNBT(message.modifiersTag);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ctx.get().setPacketHandled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,6 +32,8 @@ public class PacketHandler {
|
|||||||
PerformUndoPacket.Handler::handle, Optional.of(NetworkDirection.PLAY_TO_SERVER));
|
PerformUndoPacket.Handler::handle, Optional.of(NetworkDirection.PLAY_TO_SERVER));
|
||||||
INSTANCE.registerMessage(id++, PerformRedoPacket.class, PerformRedoPacket::encode, PerformRedoPacket::decode,
|
INSTANCE.registerMessage(id++, PerformRedoPacket.class, PerformRedoPacket::encode, PerformRedoPacket::decode,
|
||||||
PerformRedoPacket.Handler::handle, Optional.of(NetworkDirection.PLAY_TO_SERVER));
|
PerformRedoPacket.Handler::handle, Optional.of(NetworkDirection.PLAY_TO_SERVER));
|
||||||
|
INSTANCE.registerMessage(id++, ModifierSettingsPacket.class, ModifierSettingsPacket::encode, ModifierSettingsPacket::decode,
|
||||||
|
ModifierSettingsPacket.Handler::handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class BlockEntry {
|
|||||||
public boolean mirrorY;
|
public boolean mirrorY;
|
||||||
public boolean mirrorZ;
|
public boolean mirrorZ;
|
||||||
//Horizontal rotation
|
//Horizontal rotation
|
||||||
public Rotation rotation;
|
public Rotation rotation = Rotation.NONE;
|
||||||
//BlockState that is currently in the world
|
//BlockState that is currently in the world
|
||||||
public BlockState existingBlockState;
|
public BlockState existingBlockState;
|
||||||
public BlockState newBlockState;
|
public BlockState newBlockState;
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 7.9 KiB |
Reference in New Issue
Block a user