Added descriptions to radial menu. Added pyramid, cone and dome buttons, icons and placeholder classes. Fixed leftclicking to cancel in survival.
This commit is contained in:
@@ -10,8 +10,8 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.server.ServerStartingEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -23,7 +23,7 @@ import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.UndoRedo;
|
||||
import nl.requios.effortlessbuilding.capability.ModeCapabilityManager;
|
||||
import nl.requios.effortlessbuilding.capability.ModifierCapabilityManager;
|
||||
import nl.requios.effortlessbuilding.command.CommandReach;
|
||||
import nl.requios.effortlessbuilding.command.ReachCommand;
|
||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
||||
import nl.requios.effortlessbuilding.network.AddUndoMessage;
|
||||
@@ -46,8 +46,8 @@ public class EventHandler {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerStarting(ServerStartingEvent event) {
|
||||
CommandReach.register(event.getServer().getCommands().getDispatcher());
|
||||
public void onRegisterCommands(RegisterCommandsEvent event) {
|
||||
ReachCommand.register(event.getDispatcher());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -111,44 +111,44 @@ public class EventHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void breakSpeed(PlayerEvent.BreakSpeed event) {
|
||||
//Disable if config says so
|
||||
if (!BuildConfig.survivalBalancers.increasedMiningTime.get()) return;
|
||||
|
||||
if (event.getPlayer() instanceof FakePlayer) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Level world = player.level;
|
||||
BlockPos pos = event.getPos();
|
||||
|
||||
//EffortlessBuilding.log(player, String.valueOf(event.getNewSpeed()));
|
||||
|
||||
float originalBlockHardness = event.getState().getDestroySpeed(world, pos);
|
||||
if (originalBlockHardness < 0) return; //Dont break bedrock
|
||||
float totalBlockHardness = 0;
|
||||
//get coordinates
|
||||
List<BlockPos> coordinates = BuildModifiers.findCoordinates(player, pos);
|
||||
for (int i = 1; i < coordinates.size(); i++) {
|
||||
BlockPos coordinate = coordinates.get(i);
|
||||
//get existing blockstates at those coordinates
|
||||
BlockState blockState = world.getBlockState(coordinate);
|
||||
//add hardness for each blockstate, if can break
|
||||
if (SurvivalHelper.canBreak(world, player, coordinate))
|
||||
totalBlockHardness += blockState.getDestroySpeed(world, coordinate);
|
||||
}
|
||||
|
||||
//Grabbing percentage from config
|
||||
float percentage = (float) BuildConfig.survivalBalancers.miningTimePercentage.get() / 100;
|
||||
totalBlockHardness *= percentage;
|
||||
totalBlockHardness += originalBlockHardness;
|
||||
|
||||
float newSpeed = event.getOriginalSpeed() / totalBlockHardness * originalBlockHardness;
|
||||
if (Float.isNaN(newSpeed) || newSpeed == 0f) newSpeed = 1f;
|
||||
event.setNewSpeed(newSpeed);
|
||||
|
||||
//EffortlessBuilding.log(player, String.valueOf(event.getNewSpeed()));
|
||||
}
|
||||
// @SubscribeEvent
|
||||
// public static void breakSpeed(PlayerEvent.BreakSpeed event) {
|
||||
// //Disable if config says so
|
||||
// if (!BuildConfig.survivalBalancers.increasedMiningTime.get()) return;
|
||||
//
|
||||
// if (event.getPlayer() instanceof FakePlayer) return;
|
||||
//
|
||||
// Player player = event.getPlayer();
|
||||
// Level world = player.level;
|
||||
// BlockPos pos = event.getPos();
|
||||
//
|
||||
// //EffortlessBuilding.log(player, String.valueOf(event.getNewSpeed()));
|
||||
//
|
||||
// float originalBlockHardness = event.getState().getDestroySpeed(world, pos);
|
||||
// if (originalBlockHardness < 0) return; //Dont break bedrock
|
||||
// float totalBlockHardness = 0;
|
||||
// //get coordinates
|
||||
// List<BlockPos> coordinates = BuildModifiers.findCoordinates(player, pos);
|
||||
// for (int i = 1; i < coordinates.size(); i++) {
|
||||
// BlockPos coordinate = coordinates.get(i);
|
||||
// //get existing blockstates at those coordinates
|
||||
// BlockState blockState = world.getBlockState(coordinate);
|
||||
// //add hardness for each blockstate, if can break
|
||||
// if (SurvivalHelper.canBreak(world, player, coordinate))
|
||||
// totalBlockHardness += blockState.getDestroySpeed(world, coordinate);
|
||||
// }
|
||||
//
|
||||
// //Grabbing percentage from config
|
||||
// float percentage = (float) BuildConfig.survivalBalancers.miningTimePercentage.get() / 100;
|
||||
// totalBlockHardness *= percentage;
|
||||
// totalBlockHardness += originalBlockHardness;
|
||||
//
|
||||
// float newSpeed = event.getOriginalSpeed() / totalBlockHardness * originalBlockHardness;
|
||||
// if (Float.isNaN(newSpeed) || newSpeed == 0f) newSpeed = 1f;
|
||||
// event.setNewSpeed(newSpeed);
|
||||
//
|
||||
// //EffortlessBuilding.log(player, String.valueOf(event.getNewSpeed()));
|
||||
// }
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
|
||||
@@ -117,6 +117,8 @@ public class BuildModes {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ReachHelper.canBreakFar(player)) return;
|
||||
|
||||
//If first click
|
||||
if (currentlyBreaking.get(player) == null) {
|
||||
//If startpos is null, dont do anything
|
||||
@@ -245,20 +247,23 @@ public class BuildModes {
|
||||
}
|
||||
|
||||
public enum BuildModeEnum {
|
||||
NORMAL("effortlessbuilding.mode.normal", new Normal()),
|
||||
NORMAL_PLUS("effortlessbuilding.mode.normal_plus", new NormalPlus(), OptionEnum.BUILD_SPEED),
|
||||
LINE("effortlessbuilding.mode.line", new Line() /*, OptionEnum.THICKNESS*/),
|
||||
WALL("effortlessbuilding.mode.wall", new Wall(), OptionEnum.FILL),
|
||||
FLOOR("effortlessbuilding.mode.floor", new Floor(), OptionEnum.FILL),
|
||||
DIAGONAL_LINE("effortlessbuilding.mode.diagonal_line", new DiagonalLine() /*, OptionEnum.THICKNESS*/),
|
||||
DIAGONAL_WALL("effortlessbuilding.mode.diagonal_wall", new DiagonalWall() /*, OptionEnum.FILL*/),
|
||||
SLOPE_FLOOR("effortlessbuilding.mode.slope_floor", new SlopeFloor(), OptionEnum.RAISED_EDGE),
|
||||
CIRCLE("effortlessbuilding.mode.circle", new Circle(), OptionEnum.CIRCLE_START, OptionEnum.FILL),
|
||||
CYLINDER("effortlessbuilding.mode.cylinder", new Cylinder(), OptionEnum.CIRCLE_START, OptionEnum.FILL),
|
||||
SPHERE("effortlessbuilding.mode.sphere", new Sphere(), OptionEnum.CIRCLE_START, OptionEnum.FILL),
|
||||
CUBE("effortlessbuilding.mode.cube", new Cube(), OptionEnum.CUBE_FILL);
|
||||
NORMAL("normal", new Normal()),
|
||||
NORMAL_PLUS("normal_plus", new NormalPlus(), OptionEnum.BUILD_SPEED),
|
||||
LINE("line", new Line() /*, OptionEnum.THICKNESS*/),
|
||||
WALL("wall", new Wall(), OptionEnum.FILL),
|
||||
FLOOR("floor", new Floor(), OptionEnum.FILL),
|
||||
DIAGONAL_LINE("diagonal_line", new DiagonalLine() /*, OptionEnum.THICKNESS*/),
|
||||
DIAGONAL_WALL("diagonal_wall", new DiagonalWall() /*, OptionEnum.FILL*/),
|
||||
SLOPE_FLOOR("slope_floor", new SlopeFloor(), OptionEnum.RAISED_EDGE),
|
||||
CIRCLE("circle", new Circle(), OptionEnum.CIRCLE_START, OptionEnum.FILL),
|
||||
CYLINDER("cylinder", new Cylinder(), OptionEnum.CIRCLE_START, OptionEnum.FILL),
|
||||
SPHERE("sphere", new Sphere(), OptionEnum.CIRCLE_START, OptionEnum.FILL),
|
||||
CUBE("cube", new Cube(), OptionEnum.CUBE_FILL),
|
||||
PYRAMID("pyramid", new Pyramid()),
|
||||
CONE("cone", new Cone()),
|
||||
DOME("dome", new Dome());
|
||||
|
||||
public String name;
|
||||
private String name;
|
||||
public IBuildMode instance;
|
||||
public OptionEnum[] options;
|
||||
|
||||
@@ -267,5 +272,13 @@ public class BuildModes {
|
||||
this.instance = instance;
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public String getNameKey() {
|
||||
return "effortlessbuilding.mode." + name;
|
||||
}
|
||||
|
||||
public String getDescriptionKey() {
|
||||
return "effortlessbuilding.modedescription." + name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Cone extends ThreeClicksBuildMode {
|
||||
|
||||
@Override
|
||||
protected BlockPos findSecondPos(Player player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
return Floor.findFloor(player, firstPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockPos findThirdPos(Player player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||
return findHeight(player, secondPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getIntermediateBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
return Floor.getFloorBlocks(player, x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getFinalBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
//TODO
|
||||
return SlopeFloor.getSlopeFloorBlocks(player, x1, y1, z1, x2, y2, z2, x3, y3, z3);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Dome extends ThreeClicksBuildMode {
|
||||
|
||||
@Override
|
||||
protected BlockPos findSecondPos(Player player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
return Floor.findFloor(player, firstPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockPos findThirdPos(Player player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||
return findHeight(player, secondPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getIntermediateBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
return Floor.getFloorBlocks(player, x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getFinalBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
//TODO
|
||||
return SlopeFloor.getSlopeFloorBlocks(player, x1, y1, z1, x2, y2, z2, x3, y3, z3);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Pyramid extends ThreeClicksBuildMode {
|
||||
|
||||
@Override
|
||||
protected BlockPos findSecondPos(Player player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
return Floor.findFloor(player, firstPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockPos findThirdPos(Player player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||
return findHeight(player, secondPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getIntermediateBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
return Floor.getFloorBlocks(player, x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getFinalBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
//TODO
|
||||
return SlopeFloor.getSlopeFloorBlocks(player, x1, y1, z1, x2, y2, z2, x3, y3, z3);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package nl.requios.effortlessbuilding.command;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -12,14 +13,19 @@ import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||
import nl.requios.effortlessbuilding.network.ModifierSettingsMessage;
|
||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||
|
||||
public class CommandReach {
|
||||
public class ReachCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
||||
dispatcher.register(Commands.literal("reach").then(Commands.literal("set").then(Commands.argument("level", IntegerArgumentType.integer(0, 3)).executes((context) -> {
|
||||
dispatcher.register(
|
||||
Commands.literal("reach")
|
||||
.then(Commands.literal("set")
|
||||
.then(Commands.argument("level", IntegerArgumentType.integer(0, 3))
|
||||
.executes((context) -> {
|
||||
return setReachLevel(context.getSource().getPlayerOrException(), IntegerArgumentType.getInteger(context, "level"));
|
||||
}))).then(Commands.literal("get").executes((context -> {
|
||||
})))
|
||||
.then(Commands.literal("get").executes((context -> {
|
||||
return getReachLevel(context.getSource().getPlayerOrException());
|
||||
}))));
|
||||
}))));
|
||||
}
|
||||
|
||||
private static int setReachLevel(ServerPlayer player, int level) {
|
||||
@@ -2,6 +2,7 @@ package nl.requios.effortlessbuilding.gui.buildmode;
|
||||
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.math.Vector4f;
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
@@ -44,10 +45,29 @@ import nl.requios.effortlessbuilding.buildmode.ModeOptions.OptionEnum;
|
||||
@MethodsReturnNonnullByDefault
|
||||
public class RadialMenu extends Screen {
|
||||
|
||||
private final Vector4f radialButtonColor = new Vector4f(0f, 0f, 0f, .5f);
|
||||
private final Vector4f sideButtonColor = new Vector4f(.5f, .5f, .5f, .5f);
|
||||
private final Vector4f highlightColor = new Vector4f(.6f, .8f, 1f, .6f);
|
||||
private final Vector4f selectedColor = new Vector4f(0f, .5f, 1f, .5f);
|
||||
private final Vector4f highlightSelectedColor = new Vector4f(0.2f, .7f, 1f, .7f);
|
||||
|
||||
private final int whiteTextColor = 0xffffffff;
|
||||
private final int watermarkTextColor = 0x88888888;
|
||||
private final int descriptionTextColor = 0xdd888888;
|
||||
private final int optionTextColor = 0xeeeeeeff;
|
||||
|
||||
private final double ringInnerEdge = 40;
|
||||
private final double ringOuterEdge = 80;
|
||||
private final double textDistance = 90;
|
||||
private final double buttonDistance = 120;
|
||||
private final float fadeSpeed = 0.3f;
|
||||
private final int descriptionHeight = 100;
|
||||
|
||||
public static final RadialMenu instance = new RadialMenu();
|
||||
public BuildModeEnum switchTo = null;
|
||||
public ActionEnum doAction = null;
|
||||
public boolean performedActionUsingMouse;
|
||||
|
||||
private float visibility;
|
||||
|
||||
public RadialMenu() {
|
||||
@@ -81,7 +101,7 @@ public class RadialMenu extends Screen {
|
||||
ms.pushPose();
|
||||
ms.translate(0, 0, 200);
|
||||
|
||||
visibility += 0.3f * partialTicks;
|
||||
visibility += fadeSpeed * partialTicks;
|
||||
if (visibility > 1f) visibility = 1f;
|
||||
|
||||
final int startColor = (int) (visibility * 98) << 24;
|
||||
@@ -109,10 +129,6 @@ public class RadialMenu extends Screen {
|
||||
final double mouseYCenter = mouseYY - middleY;
|
||||
double mouseRadians = Math.atan2(mouseYCenter, mouseXCenter);
|
||||
|
||||
final double ringInnerEdge = 30;
|
||||
final double ringOuterEdge = 65;
|
||||
final double textDistance = 75;
|
||||
final double buttonDistance = 105;
|
||||
final double quarterCircle = Math.PI / 2.0;
|
||||
|
||||
if (mouseRadians < -quarterCircle) {
|
||||
@@ -147,10 +163,10 @@ public class RadialMenu extends Screen {
|
||||
doAction = null;
|
||||
|
||||
//Draw buildmode backgrounds
|
||||
drawBuildModeBackgrounds(currentBuildMode, buffer, middleX, middleY, mouseXCenter, mouseYCenter, mouseRadians, ringInnerEdge, ringOuterEdge, quarterCircle, modes);
|
||||
drawRadialButtonBackgrounds(currentBuildMode, buffer, middleX, middleY, mouseXCenter, mouseYCenter, mouseRadians, ringInnerEdge, ringOuterEdge, quarterCircle, modes);
|
||||
|
||||
//Draw action backgrounds
|
||||
drawActionBackgrounds(buffer, middleX, middleY, mouseXCenter, mouseYCenter, buttons);
|
||||
drawSideButtonBackgrounds(buffer, middleX, middleY, mouseXCenter, mouseYCenter, buttons);
|
||||
|
||||
tessellator.end();
|
||||
RenderSystem.disableBlend();
|
||||
@@ -163,7 +179,7 @@ public class RadialMenu extends Screen {
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
private void drawBuildModeBackgrounds(BuildModeEnum currentBuildMode, BufferBuilder buffer, double middleX, double middleY, double mouseXCenter, double mouseYCenter, double mouseRadians, double ringInnerEdge, double ringOuterEdge, double quarterCircle, ArrayList<MenuRegion> modes) {
|
||||
private void drawRadialButtonBackgrounds(BuildModeEnum currentBuildMode, BufferBuilder buffer, double middleX, double middleY, double mouseXCenter, double mouseYCenter, double mouseRadians, double ringInnerEdge, double ringOuterEdge, double quarterCircle, ArrayList<MenuRegion> modes) {
|
||||
if (!modes.isEmpty()) {
|
||||
final int totalModes = Math.max(3, modes.size());
|
||||
int currentMode = 0;
|
||||
@@ -191,78 +207,58 @@ public class RadialMenu extends Screen {
|
||||
final double y1m2 = Math.sin(beginRadians + fragment2) * ringOuterEdge;
|
||||
final double y2m2 = Math.sin(endRadians - fragment2) * ringOuterEdge;
|
||||
|
||||
float r = 0.0f;
|
||||
float g = 0.0f;
|
||||
float b = 0.0f;
|
||||
float a = 0.5f;
|
||||
|
||||
//check if current mode
|
||||
int buildMode = currentBuildMode.ordinal();
|
||||
if (buildMode == i) {
|
||||
r = 0f;
|
||||
g = 0.5f;
|
||||
b = 1f;
|
||||
a = 0.5f;
|
||||
//menuRegion.highlighted = true; //draw text
|
||||
}
|
||||
|
||||
//check if mouse is over this region
|
||||
final boolean isSelected = currentBuildMode.ordinal() == i;
|
||||
final boolean isMouseInQuad = inTriangle(x1m1, y1m1, x2m2, y2m2, x2m1, y2m1, mouseXCenter, mouseYCenter)
|
||||
|| inTriangle(x1m1, y1m1, x1m2, y1m2, x2m2, y2m2, mouseXCenter, mouseYCenter);
|
||||
final boolean isHighlighted = beginRadians <= mouseRadians && mouseRadians <= endRadians && isMouseInQuad;
|
||||
|
||||
if (beginRadians <= mouseRadians && mouseRadians <= endRadians && isMouseInQuad) {
|
||||
r = 0.6f;
|
||||
g = 0.8f;
|
||||
b = 1f;
|
||||
a = 0.6f;
|
||||
Vector4f color = radialButtonColor;
|
||||
if (isSelected) color = selectedColor;
|
||||
if (isHighlighted) color = highlightColor;
|
||||
if (isSelected && isHighlighted) color = highlightSelectedColor;
|
||||
|
||||
if (isHighlighted) {
|
||||
menuRegion.highlighted = true;
|
||||
switchTo = menuRegion.mode;
|
||||
}
|
||||
|
||||
buffer.vertex(middleX + x1m1, middleY + y1m1, getBlitOffset()).color(r, g, b, a).endVertex();
|
||||
buffer.vertex(middleX + x2m1, middleY + y2m1, getBlitOffset()).color(r, g, b, a).endVertex();
|
||||
buffer.vertex(middleX + x2m2, middleY + y2m2, getBlitOffset()).color(r, g, b, a).endVertex();
|
||||
buffer.vertex(middleX + x1m2, middleY + y1m2, getBlitOffset()).color(r, g, b, a).endVertex();
|
||||
buffer.vertex(middleX + x1m1, middleY + y1m1, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||
buffer.vertex(middleX + x2m1, middleY + y2m1, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||
buffer.vertex(middleX + x2m2, middleY + y2m2, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||
buffer.vertex(middleX + x1m2, middleY + y1m2, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||
|
||||
currentMode++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawActionBackgrounds(BufferBuilder buffer, double middleX, double middleY, double mouseXCenter, double mouseYCenter, ArrayList<MenuButton> buttons) {
|
||||
private void drawSideButtonBackgrounds(BufferBuilder buffer, double middleX, double middleY, double mouseXCenter, double mouseYCenter, ArrayList<MenuButton> buttons) {
|
||||
for (final MenuButton btn : buttons) {
|
||||
float r = 0.5f;
|
||||
float g = 0.5f;
|
||||
float b = 0.5f;
|
||||
float a = 0.5f;
|
||||
|
||||
//highlight when active option
|
||||
if (btn.action == getBuildSpeed() ||
|
||||
btn.action == getFill() ||
|
||||
btn.action == getCubeFill() ||
|
||||
btn.action == getRaisedEdge() ||
|
||||
btn.action == getLineThickness() ||
|
||||
btn.action == getCircleStart()) {
|
||||
r = 0.0f;
|
||||
g = 0.5f;
|
||||
b = 1f;
|
||||
a = 0.6f;
|
||||
}
|
||||
final boolean isSelected =
|
||||
btn.action == getBuildSpeed() ||
|
||||
btn.action == getFill() ||
|
||||
btn.action == getCubeFill() ||
|
||||
btn.action == getRaisedEdge() ||
|
||||
btn.action == getLineThickness() ||
|
||||
btn.action == getCircleStart();
|
||||
|
||||
//highlight when mouse over
|
||||
if (btn.x1 <= mouseXCenter && btn.x2 >= mouseXCenter && btn.y1 <= mouseYCenter && btn.y2 >= mouseYCenter) {
|
||||
r = 0.6f;
|
||||
g = 0.8f;
|
||||
b = 1f;
|
||||
a = 0.6f;
|
||||
final boolean isHighlighted = btn.x1 <= mouseXCenter && btn.x2 >= mouseXCenter && btn.y1 <= mouseYCenter && btn.y2 >= mouseYCenter;
|
||||
|
||||
Vector4f color = sideButtonColor;
|
||||
if (isSelected) color = selectedColor;
|
||||
if (isHighlighted) color = highlightColor;
|
||||
if (isSelected && isHighlighted) color = highlightSelectedColor;
|
||||
|
||||
if (isHighlighted) {
|
||||
btn.highlighted = true;
|
||||
doAction = btn.action;
|
||||
}
|
||||
|
||||
buffer.vertex(middleX + btn.x1, middleY + btn.y1, getBlitOffset()).color(r, g, b, a).endVertex();
|
||||
buffer.vertex(middleX + btn.x1, middleY + btn.y2, getBlitOffset()).color(r, g, b, a).endVertex();
|
||||
buffer.vertex(middleX + btn.x2, middleY + btn.y2, getBlitOffset()).color(r, g, b, a).endVertex();
|
||||
buffer.vertex(middleX + btn.x2, middleY + btn.y1, getBlitOffset()).color(r, g, b, a).endVertex();
|
||||
buffer.vertex(middleX + btn.x1, middleY + btn.y1, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||
buffer.vertex(middleX + btn.x1, middleY + btn.y2, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||
buffer.vertex(middleX + btn.x2, middleY + btn.y2, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||
buffer.vertex(middleX + btn.x2, middleY + btn.y1, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,8 +271,8 @@ public class RadialMenu extends Screen {
|
||||
//Draw buildmode icons
|
||||
for (final MenuRegion menuRegion : modes) {
|
||||
|
||||
final double x = (menuRegion.x1 + menuRegion.x2) * 0.5 * (ringOuterEdge * 0.6 + 0.4 * ringInnerEdge);
|
||||
final double y = (menuRegion.y1 + menuRegion.y2) * 0.5 * (ringOuterEdge * 0.6 + 0.4 * ringInnerEdge);
|
||||
final double x = (menuRegion.x1 + menuRegion.x2) * 0.5 * (ringOuterEdge * 0.55 + 0.45 * ringInnerEdge);
|
||||
final double y = (menuRegion.y1 + menuRegion.y2) * 0.5 * (ringOuterEdge * 0.55 + 0.45 * ringInnerEdge);
|
||||
|
||||
RenderSystem.setShaderTexture(0, new ResourceLocation(EffortlessBuilding.MODID, "textures/icons/" + menuRegion.mode.name().toLowerCase() + ".png"));
|
||||
blit(ms, (int) (middleX + x - 8), (int) (middleY + y - 8), 16, 16, 0, 0, 18, 18, 18, 18);
|
||||
@@ -301,11 +297,11 @@ public class RadialMenu extends Screen {
|
||||
//Draw option strings
|
||||
for (int i = 0; i < currentBuildMode.options.length; i++) {
|
||||
OptionEnum option = options[i];
|
||||
font.drawShadow(ms, I18n.get(option.name), (int) (middleX + buttonDistance - 9), (int) middleY - 37 + i * 39, 0xeeeeeeff);
|
||||
font.drawShadow(ms, I18n.get(option.name), (int) (middleX + buttonDistance - 9), (int) middleY - 37 + i * 39, optionTextColor);
|
||||
}
|
||||
|
||||
String credits = "Effortless Building";
|
||||
font.drawShadow(ms, credits, width - font.width(credits) - 4, height - 10, 0x88888888);
|
||||
font.drawShadow(ms, credits, width - font.width(credits) - 4, height - 10, watermarkTextColor);
|
||||
|
||||
//Draw buildmode text
|
||||
for (final MenuRegion menuRegion : modes) {
|
||||
@@ -315,8 +311,8 @@ public class RadialMenu extends Screen {
|
||||
final double y = (menuRegion.y1 + menuRegion.y2) * 0.5;
|
||||
|
||||
int fixed_x = (int) (x * textDistance);
|
||||
final int fixed_y = (int) (y * textDistance) - font.lineHeight / 2;
|
||||
final String text = I18n.get(menuRegion.mode.name);
|
||||
int fixed_y = (int) (y * textDistance) - font.lineHeight / 2;
|
||||
String text = I18n.get(menuRegion.mode.getNameKey());
|
||||
|
||||
if (x <= -0.2) {
|
||||
fixed_x -= font.width(text);
|
||||
@@ -324,7 +320,11 @@ public class RadialMenu extends Screen {
|
||||
fixed_x -= font.width(text) / 2;
|
||||
}
|
||||
|
||||
font.drawShadow(ms, text, (int) middleX + fixed_x, (int) middleY + fixed_y, 0xffffffff);
|
||||
font.drawShadow(ms, text, (int) middleX + fixed_x, (int) middleY + fixed_y, whiteTextColor);
|
||||
|
||||
//Draw description
|
||||
text = I18n.get(menuRegion.mode.getDescriptionKey());
|
||||
font.drawShadow(ms, text, (int) middleX - font.width(text) / 2f, (int) middleY + descriptionHeight, descriptionTextColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,28 +342,28 @@ public class RadialMenu extends Screen {
|
||||
if (button.textSide == Direction.WEST) {
|
||||
|
||||
font.draw(ms, text, (int) (middleX + button.x1 - 8) - font.width(text),
|
||||
(int) (middleY + button.y1 + 6), 0xffffffff);
|
||||
(int) (middleY + button.y1 + 6), whiteTextColor);
|
||||
|
||||
} else if (button.textSide == Direction.EAST) {
|
||||
|
||||
font.draw(ms, text, (int) (middleX + button.x2 + 8),
|
||||
(int) (middleY + button.y1 + 6), 0xffffffff);
|
||||
(int) (middleY + button.y1 + 6), whiteTextColor);
|
||||
|
||||
} else if (button.textSide == Direction.UP || button.textSide == Direction.NORTH) {
|
||||
|
||||
font.draw(ms, keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(keybindFormatted) * 0.5),
|
||||
(int) (middleY + button.y1 - 26), 0xffffffff);
|
||||
(int) (middleY + button.y1 - 26), whiteTextColor);
|
||||
|
||||
font.draw(ms, text, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(text) * 0.5),
|
||||
(int) (middleY + button.y1 - 14), 0xffffffff);
|
||||
(int) (middleY + button.y1 - 14), whiteTextColor);
|
||||
|
||||
} else if (button.textSide == Direction.DOWN || button.textSide == Direction.SOUTH) {
|
||||
|
||||
font.draw(ms, text, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(text) * 0.5),
|
||||
(int) (middleY + button.y1 + 26), 0xffffffff);
|
||||
(int) (middleY + button.y1 + 26), whiteTextColor);
|
||||
|
||||
font.draw(ms, keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(keybindFormatted) * 0.5),
|
||||
(int) (middleY + button.y1 + 38), 0xffffffff);
|
||||
(int) (middleY + button.y1 + 38), whiteTextColor);
|
||||
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ public class RadialMenu extends Screen {
|
||||
ModeSettingsManager.setModeSettings(player, modeSettings);
|
||||
PacketHandler.INSTANCE.sendToServer(new ModeSettingsMessage(modeSettings));
|
||||
|
||||
EffortlessBuilding.log(player, I18n.get(modeSettings.getBuildMode().name), true);
|
||||
EffortlessBuilding.log(player, I18n.get(modeSettings.getBuildMode().getNameKey()), true);
|
||||
|
||||
if (fromMouseClick) performedActionUsingMouse = true;
|
||||
}
|
||||
|
||||
@@ -192,12 +192,6 @@ public class ClientProxy implements IProxy {
|
||||
if (breakCooldown <= 0) {
|
||||
breakCooldown = 4;
|
||||
|
||||
//Early out if cant break far, coming from own mouse event (not block broken event)
|
||||
//To make breaking blocks in survival possible like array
|
||||
//TODO this causes not being able to cancel placement in survival
|
||||
// moving it to after buildmodes fixes that, but introduces this bug
|
||||
if (!ReachHelper.canBreakFar(player)) return;
|
||||
|
||||
HitResult lookingAt = getLookingAt(player);
|
||||
if (lookingAt != null && lookingAt.getType() == HitResult.Type.BLOCK) {
|
||||
BlockHitResult blockLookingAt = (BlockHitResult) lookingAt;
|
||||
|
||||
Reference in New Issue
Block a user