Renamed reach to power level. Separated reach config for more control.
Added draft icons for elastic hand, muscles and building technique book. Separated BlockUtilities clientside.
This commit is contained in:
@@ -20,7 +20,7 @@ import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
import nl.requios.effortlessbuilding.gui.buildmode.PlayerSettingsGui;
|
||||
import nl.requios.effortlessbuilding.gui.buildmode.RadialMenu;
|
||||
import nl.requios.effortlessbuilding.gui.buildmodifier.ModifiersScreen;
|
||||
import nl.requios.effortlessbuilding.utilities.ReachHelper;
|
||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
@EventBusSubscriber(Dist.CLIENT)
|
||||
@@ -137,7 +137,7 @@ public class ClientEvents {
|
||||
|
||||
//Radial menu
|
||||
if (keyBindings[0].isDown()) {
|
||||
if (ReachHelper.getMaxReach(player) > 0) {
|
||||
if (!EffortlessBuildingClient.POWER_LEVEL.isDisabled(player)) {
|
||||
if (!RadialMenu.instance.isVisible()) {
|
||||
Minecraft.getInstance().setScreen(RadialMenu.instance);
|
||||
}
|
||||
@@ -178,8 +178,8 @@ public class ClientEvents {
|
||||
if (player == null) return;
|
||||
|
||||
//Disabled if max reach is 0, might be set in the config that way.
|
||||
if (ReachHelper.getMaxReach(player) == 0) {
|
||||
EffortlessBuilding.log(player, "Build modifiers are disabled until your reach has increased. Increase your reach with craftable reach upgrades.");
|
||||
if (EffortlessBuildingClient.POWER_LEVEL.isDisabled(player)) {
|
||||
EffortlessBuilding.log(player, "Build modifiers are disabled until your power level has increased. Increase your power level by consuming certain items.");
|
||||
} else {
|
||||
mc.setScreen(new ModifiersScreen());
|
||||
}
|
||||
|
||||
@@ -10,36 +10,36 @@ public class CommonConfig {
|
||||
public static final Reach reach = new Reach(builder);
|
||||
public static final MaxBlocksPlacedAtOnce maxBlocksPlacedAtOnce = new MaxBlocksPlacedAtOnce(builder);
|
||||
public static final MaxBlocksPerAxis maxBlocksPerAxis = new MaxBlocksPerAxis(builder);
|
||||
public static final MaxMirrorRadius maxMirrorRadius = new MaxMirrorRadius(builder);
|
||||
public static final ForgeConfigSpec spec = builder.build();
|
||||
|
||||
public static class Reach {
|
||||
public final IntValue reachCreative;
|
||||
public final IntValue reachLevel0;
|
||||
public final IntValue reachLevel1;
|
||||
public final IntValue reachLevel2;
|
||||
public final IntValue reachLevel3;
|
||||
public final IntValue creative;
|
||||
public final IntValue level0;
|
||||
public final IntValue level1;
|
||||
public final IntValue level2;
|
||||
public final IntValue level3;
|
||||
|
||||
public Reach(Builder builder) {
|
||||
builder.push("Reach");
|
||||
|
||||
reachCreative = builder
|
||||
creative = builder
|
||||
.comment("How far away the player can place and break blocks.")
|
||||
.defineInRange("maxReachCreative", 200, 0, 10000);
|
||||
.defineInRange("reachCreative", 200, 0, 1000);
|
||||
|
||||
reachLevel0 = builder
|
||||
level0 = builder
|
||||
.comment("Maximum reach in survival without upgrades",
|
||||
"Reach upgrades are craftable consumables that permanently increase reach.",
|
||||
"Set to 0 to disable Effortless Building until the player has consumed a reach upgrade.")
|
||||
.defineInRange("reachLevel0", 20, 0, 10000);
|
||||
"Consume Power Level upgrades upgrades to permanently increase this.")
|
||||
.defineInRange("reachLevel0", 0, 0, 1000);
|
||||
|
||||
reachLevel1 = builder
|
||||
.defineInRange("reachLevel1", 50, 0, 10000);
|
||||
level1 = builder
|
||||
.defineInRange("reachLevel1", 8, 0, 1000);
|
||||
|
||||
reachLevel2 = builder
|
||||
.defineInRange("reachLevel2", 100, 0, 10000);
|
||||
level2 = builder
|
||||
.defineInRange("reachLevel2", 16, 0, 1000);
|
||||
|
||||
reachLevel3 = builder
|
||||
.defineInRange("reachLevel3", 200, 0, 10000);
|
||||
level3 = builder
|
||||
.defineInRange("reachLevel3", 32, 0, 1000);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
@@ -57,20 +57,22 @@ public class CommonConfig {
|
||||
|
||||
creative = builder
|
||||
.comment("How many blocks can be placed in one click.")
|
||||
.defineInRange("maxBlocksPlacedAtOnceCreative", 10000, 0, 10000);
|
||||
.defineInRange("maxBlocksPlacedAtOnceCreative", 10000, 0, 100000);
|
||||
|
||||
level0 = builder
|
||||
.comment("Maximum blocks placed at once in survival without upgrades")
|
||||
.defineInRange("maxBlocksPlacedAtOnceLevel0", 100, 0, 10000);
|
||||
.comment("In survival without upgrades",
|
||||
"Consume Power Level upgrades upgrades to permanently increase this.",
|
||||
"Set to 0 to disable Effortless Building until the player has increased their Building Power Level.")
|
||||
.defineInRange("maxBlocksPlacedAtOnceLevel0", 128, 0, 100000);
|
||||
|
||||
level1 = builder
|
||||
.defineInRange("maxBlocksPlacedAtOnceLevel1", 200, 0, 10000);
|
||||
.defineInRange("maxBlocksPlacedAtOnceLevel1", 192, 0, 100000);
|
||||
|
||||
level2 = builder
|
||||
.defineInRange("maxBlocksPlacedAtOnceLevel2", 500, 0, 10000);
|
||||
.defineInRange("maxBlocksPlacedAtOnceLevel2", 320, 0, 100000);
|
||||
|
||||
level3 = builder
|
||||
.defineInRange("maxBlocksPlacedAtOnceLevel3", 1000, 0, 10000);
|
||||
.defineInRange("maxBlocksPlacedAtOnceLevel3", 640, 0, 100000);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
@@ -88,20 +90,53 @@ public class CommonConfig {
|
||||
|
||||
creative = builder
|
||||
.comment("How many blocks can be placed at once per axis.")
|
||||
.defineInRange("maxBlocksPerAxisCreative", 10000, 0, 10000);
|
||||
.defineInRange("maxBlocksPerAxisCreative", 1000, 0, 1000);
|
||||
|
||||
level0 = builder
|
||||
.comment("Maximum blocks placed at once in survival without upgrades")
|
||||
.defineInRange("maxBlocksPerAxisLevel0", 100, 0, 10000);
|
||||
.comment("In survival without upgrades",
|
||||
"Consume Power Level upgrades upgrades to permanently increase this.")
|
||||
.defineInRange("maxBlocksPerAxisLevel0", 8, 0, 1000);
|
||||
|
||||
level1 = builder
|
||||
.defineInRange("maxBlocksPerAxisLevel1", 200, 0, 10000);
|
||||
.defineInRange("maxBlocksPerAxisLevel1", 12, 0, 1000);
|
||||
|
||||
level2 = builder
|
||||
.defineInRange("maxBlocksPerAxisLevel2", 500, 0, 10000);
|
||||
.defineInRange("maxBlocksPerAxisLevel2", 16, 0, 1000);
|
||||
|
||||
level3 = builder
|
||||
.defineInRange("maxBlocksPerAxisLevel3", 1000, 0, 10000);
|
||||
.defineInRange("maxBlocksPerAxisLevel3", 20, 0, 1000);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
}
|
||||
|
||||
public static class MaxMirrorRadius {
|
||||
public final IntValue creative;
|
||||
public final IntValue level0;
|
||||
public final IntValue level1;
|
||||
public final IntValue level2;
|
||||
public final IntValue level3;
|
||||
|
||||
public MaxMirrorRadius(Builder builder) {
|
||||
builder.push("MaxMirrorRadius");
|
||||
|
||||
creative = builder
|
||||
.comment("The maximum (radial) mirror radius.")
|
||||
.defineInRange("maxMirrorRadiusCreative", 200, 0, 1000);
|
||||
|
||||
level0 = builder
|
||||
.comment("Maximum reach in survival without upgrades",
|
||||
"Consume Power Level upgrades upgrades to permanently increase this.")
|
||||
.defineInRange("maxMirrorRadiusLevel0", 16, 0, 1000);
|
||||
|
||||
level1 = builder
|
||||
.defineInRange("maxMirrorRadiusLevel1", 32, 0, 1000);
|
||||
|
||||
level2 = builder
|
||||
.defineInRange("maxMirrorRadiusLevel2", 48, 0, 1000);
|
||||
|
||||
level3 = builder
|
||||
.defineInRange("maxMirrorRadiusLevel3", 64, 0, 1000);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ import net.minecraftforge.network.PacketDistributor;
|
||||
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
||||
import nl.requios.effortlessbuilding.network.ModifierSettingsPacket;
|
||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
||||
import nl.requios.effortlessbuilding.systems.ServerBuildState;
|
||||
import nl.requios.effortlessbuilding.utilities.ReachHelper;
|
||||
|
||||
@EventBusSubscriber
|
||||
public class CommonEvents {
|
||||
@@ -68,7 +68,7 @@ public class CommonEvents {
|
||||
//Don't cancel event if our custom logic is breaking blocks
|
||||
if (EffortlessBuilding.SERVER_BLOCK_PLACER.isPlacingOrBreakingBlocks()) return;
|
||||
|
||||
if (!ServerBuildState.isLikeVanilla(player) && ReachHelper.canBreakFar(player)) {
|
||||
if (!ServerBuildState.isLikeVanilla(player) && PowerLevel.canBreakFar(player)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,7 @@ import nl.requios.effortlessbuilding.gui.DiamondRandomizerBagScreen;
|
||||
import nl.requios.effortlessbuilding.gui.GoldenRandomizerBagScreen;
|
||||
import nl.requios.effortlessbuilding.gui.RandomizerBagScreen;
|
||||
import nl.requios.effortlessbuilding.render.BlockPreviews;
|
||||
import nl.requios.effortlessbuilding.systems.BuilderChain;
|
||||
import nl.requios.effortlessbuilding.systems.BuildSettings;
|
||||
import nl.requios.effortlessbuilding.systems.BuilderFilter;
|
||||
import nl.requios.effortlessbuilding.systems.ItemUsageTracker;
|
||||
import nl.requios.effortlessbuilding.systems.*;
|
||||
|
||||
public class EffortlessBuildingClient {
|
||||
|
||||
@@ -23,6 +20,7 @@ public class EffortlessBuildingClient {
|
||||
public static final BlockPreviews BLOCK_PREVIEWS = new BlockPreviews();
|
||||
public static final BuilderFilter BUILDER_FILTER = new BuilderFilter();
|
||||
public static final ItemUsageTracker ITEM_USAGE_TRACKER = new ItemUsageTracker();
|
||||
public static final PowerLevel POWER_LEVEL = new PowerLevel();
|
||||
|
||||
public static void onConstructorClient(IEventBus modEventBus, IEventBus forgeEventBus) {
|
||||
modEventBus.addListener(EffortlessBuildingClient::clientSetup);
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.world.phys.Vec3;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||
import nl.requios.effortlessbuilding.utilities.ReachHelper;
|
||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -65,7 +65,7 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
|
||||
if (secondPos == null) return;
|
||||
|
||||
//Limit amount of blocks we can place per row
|
||||
int axisLimit = ReachHelper.getMaxBlocksPerAxis(player);
|
||||
int axisLimit = EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPerAxis(player);
|
||||
|
||||
int x1 = firstPos.getX(), x2 = secondPos.getX();
|
||||
int y1 = firstPos.getY(), y2 = secondPos.getY();
|
||||
@@ -94,7 +94,7 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
|
||||
if (thirdPos == null) return;
|
||||
|
||||
//Limit amount of blocks you can place per row
|
||||
int axisLimit = ReachHelper.getMaxBlocksPerAxis(player);
|
||||
int axisLimit = EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPerAxis(player);
|
||||
|
||||
int x1 = firstPos.getX(), x2 = secondPos.getX(), x3 = thirdPos.getX();
|
||||
int y1 = firstPos.getY(), y2 = secondPos.getY(), y3 = thirdPos.getY();
|
||||
@@ -140,7 +140,7 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
|
||||
criteriaList.add(new HeightCriteria(zBound, secondPos, start));
|
||||
|
||||
//Remove invalid criteria
|
||||
int reach = ReachHelper.getPlacementReach(player) * 4; //4 times as much as normal placement reach
|
||||
int reach = EffortlessBuildingClient.POWER_LEVEL.getBuildModeReach(player);
|
||||
criteriaList.removeIf(criteria -> !criteria.isValid(start, look, reach, player, skipRaytrace));
|
||||
|
||||
//If none are valid, return empty list of blocks
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.world.entity.player.Player;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||
import nl.requios.effortlessbuilding.utilities.ReachHelper;
|
||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -49,7 +49,7 @@ public abstract class TwoClicksBuildMode extends BaseBuildMode {
|
||||
if (secondPos == null) return;
|
||||
|
||||
//Limit amount of blocks we can place per row
|
||||
int axisLimit = ReachHelper.getMaxBlocksPerAxis(player);
|
||||
int axisLimit = EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPerAxis(player);
|
||||
|
||||
int x1 = firstPos.getX(), x2 = secondPos.getX();
|
||||
int y1 = firstPos.getY(), y2 = secondPos.getY();
|
||||
|
||||
@@ -3,10 +3,11 @@ package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
|
||||
import nl.requios.effortlessbuilding.utilities.ReachHelper;
|
||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -24,7 +25,7 @@ public class Floor extends TwoClicksBuildMode {
|
||||
criteriaList.add(new Criteria(yBound, start));
|
||||
|
||||
//Remove invalid criteria
|
||||
int reach = ReachHelper.getPlacementReach(player) * 4; //4 times as much as normal placement reach
|
||||
int reach = EffortlessBuildingClient.POWER_LEVEL.getBuildModeReach(player);
|
||||
criteriaList.removeIf(criteria -> !criteria.isValid(start, look, reach, player, skipRaytrace));
|
||||
|
||||
//If none are valid, return empty list of blocks
|
||||
|
||||
@@ -3,9 +3,10 @@ package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
|
||||
import nl.requios.effortlessbuilding.utilities.ReachHelper;
|
||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -31,7 +32,7 @@ public class Line extends TwoClicksBuildMode {
|
||||
criteriaList.add(new Criteria(zBound, firstPos, start));
|
||||
|
||||
//Remove invalid criteria
|
||||
int reach = ReachHelper.getPlacementReach(player) * 4; //4 times as much as normal placement reach
|
||||
int reach = EffortlessBuildingClient.POWER_LEVEL.getBuildModeReach(player);
|
||||
criteriaList.removeIf(criteria -> !criteria.isValid(start, look, reach, player, skipRaytrace));
|
||||
|
||||
//If none are valid, return empty list of blocks
|
||||
|
||||
@@ -2,9 +2,10 @@ package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||
import nl.requios.effortlessbuilding.utilities.ReachHelper;
|
||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -15,7 +16,7 @@ public class SlopeFloor extends ThreeClicksBuildMode {
|
||||
public static List<BlockPos> getSlopeFloorBlocks(Player player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
|
||||
int axisLimit = ReachHelper.getMaxBlocksPerAxis(player);
|
||||
int axisLimit = EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPerAxis(player);
|
||||
|
||||
//Determine whether to use x or z axis to slope up
|
||||
boolean onXAxis = true;
|
||||
|
||||
@@ -3,10 +3,11 @@ package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
|
||||
import nl.requios.effortlessbuilding.utilities.ReachHelper;
|
||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -28,7 +29,7 @@ public class Wall extends TwoClicksBuildMode {
|
||||
criteriaList.add(new Criteria(zBound, firstPos, start, look));
|
||||
|
||||
//Remove invalid criteria
|
||||
int reach = ReachHelper.getPlacementReach(player) * 4; //4 times as much as normal placement reach
|
||||
int reach = EffortlessBuildingClient.POWER_LEVEL.getBuildModeReach(player);
|
||||
criteriaList.removeIf(criteria -> !criteria.isValid(start, look, reach, player, skipRaytrace));
|
||||
|
||||
//If none are valid, return empty list of blocks
|
||||
|
||||
@@ -42,6 +42,11 @@ public class Array extends BaseModifier {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPowerLevelChanged(int powerLevel) {
|
||||
|
||||
}
|
||||
|
||||
public int getReach() {
|
||||
//find largest offset
|
||||
int x = Math.abs(offset.getX());
|
||||
|
||||
@@ -10,6 +10,8 @@ public abstract class BaseModifier {
|
||||
|
||||
public abstract void findCoordinates(BlockSet blocks, Player player);
|
||||
|
||||
public abstract void onPowerLevelChanged(int powerLevel);
|
||||
|
||||
public CompoundTag serializeNBT() {
|
||||
CompoundTag compound = new CompoundTag();
|
||||
compound.putString("type", this.getClass().getSimpleName());
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package nl.requios.effortlessbuilding.buildmodifier;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.NBTHelper;
|
||||
import nl.requios.effortlessbuilding.network.ModifierSettingsPacket;
|
||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||
@@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class BuildModifiers {
|
||||
private List<BaseModifier> modifierSettingsList = new ArrayList<>();
|
||||
|
||||
@@ -73,6 +74,12 @@ public class BuildModifiers {
|
||||
}
|
||||
}
|
||||
|
||||
public void onPowerLevelChanged(int powerLevel) {
|
||||
for (BaseModifier modifierSettings : modifierSettingsList) {
|
||||
modifierSettings.onPowerLevelChanged(powerLevel);
|
||||
}
|
||||
}
|
||||
|
||||
public CompoundTag serializeNBT() {
|
||||
var compoundTag = new CompoundTag();
|
||||
compoundTag.put("modifierSettingsList", NBTHelper.writeCompoundList(modifierSettingsList, BaseModifier::serializeNBT));
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||
|
||||
@@ -41,6 +42,11 @@ public class Mirror extends BaseModifier {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPowerLevelChanged(int powerLevel) {
|
||||
radius = EffortlessBuildingClient.POWER_LEVEL.getMaxMirrorRadius(Minecraft.getInstance().player);
|
||||
}
|
||||
|
||||
private void performMirrorX(BlockSet blocks, BlockEntry blockEntry) {
|
||||
//find mirror position
|
||||
double x = position.x + (position.x - blockEntry.blockPos.getX() - 0.5);
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.item.AbstractRandomizerBagItem;
|
||||
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||
@@ -48,6 +49,11 @@ public class RadialMirror extends BaseModifier {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPowerLevelChanged(int powerLevel) {
|
||||
radius = EffortlessBuildingClient.POWER_LEVEL.getMaxMirrorRadius(Minecraft.getInstance().player);
|
||||
}
|
||||
|
||||
public void performRadialMirror(BlockSet blocks, BlockEntry blockEntry) {
|
||||
|
||||
//get angle between slices
|
||||
|
||||
@@ -7,12 +7,13 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import nl.requios.effortlessbuilding.AllGuiTextures;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.Array;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.ScrollInput;
|
||||
import nl.requios.effortlessbuilding.gui.elements.LabeledScrollInput;
|
||||
import nl.requios.effortlessbuilding.utilities.MathHelper;
|
||||
import nl.requios.effortlessbuilding.utilities.ReachHelper;
|
||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
@@ -85,7 +86,7 @@ public class ArrayEntry extends BaseModifierEntry<Array> {
|
||||
super.onValueChanged();
|
||||
|
||||
int currentReach = Math.max(-1, getArrayReach());
|
||||
int maxReach = ReachHelper.getMaxReach(Minecraft.getInstance().player);
|
||||
int maxReach = EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPerAxis(Minecraft.getInstance().player);
|
||||
ChatFormatting reachColor = isCurrentReachValid(currentReach, maxReach) ? ChatFormatting.GRAY : ChatFormatting.RED;
|
||||
var reachText = "" + reachColor + currentReach + ChatFormatting.GRAY + "/" + ChatFormatting.GRAY + maxReach;
|
||||
reachLabel.text = Component.literal(reachText);
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import nl.requios.effortlessbuilding.AllGuiTextures;
|
||||
import nl.requios.effortlessbuilding.AllIcons;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.Mirror;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.IconButton;
|
||||
@@ -15,7 +16,7 @@ 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.systems.PowerLevel;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Vector;
|
||||
@@ -101,7 +102,7 @@ public class MirrorEntry extends BaseModifierEntry<Mirror> {
|
||||
|
||||
//Radius
|
||||
radiusInput = new LabeledScrollInput(0, 0, 27, 18)
|
||||
.withRange(0, ReachHelper.getMaxMirrorRadius(Minecraft.getInstance().player))
|
||||
.withRange(0, EffortlessBuildingClient.POWER_LEVEL.getMaxMirrorRadius(Minecraft.getInstance().player))
|
||||
.titled(Minecraft.getInstance().player.isCreative() ?
|
||||
Component.literal("Radius") :
|
||||
Component.literal("Radius. Use Reach Upgrade items to increase maximum."))
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import nl.requios.effortlessbuilding.AllGuiTextures;
|
||||
import nl.requios.effortlessbuilding.AllIcons;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.RadialMirror;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.IconButton;
|
||||
@@ -15,7 +16,7 @@ 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.systems.PowerLevel;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Vector;
|
||||
@@ -107,7 +108,7 @@ public class RadialMirrorEntry extends BaseModifierEntry<RadialMirror> {
|
||||
|
||||
//Radius
|
||||
radiusInput = new LabeledScrollInput(0, 0, 27, 18)
|
||||
.withRange(0, ReachHelper.getMaxMirrorRadius(Minecraft.getInstance().player))
|
||||
.withRange(0, EffortlessBuildingClient.POWER_LEVEL.getMaxMirrorRadius(Minecraft.getInstance().player))
|
||||
.titled(Minecraft.getInstance().player.isCreative() ?
|
||||
Component.literal("Radius") :
|
||||
Component.literal("Radius. Use Reach Upgrade items to increase maximum."))
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.world.level.Level;
|
||||
import nl.requios.effortlessbuilding.CommonConfig;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.utilities.ReachHelper;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -39,18 +39,18 @@ public class ReachUpgrade1Item extends Item {
|
||||
return new InteractionResultHolder<>(InteractionResult.PASS, player.getItemInHand(hand));
|
||||
}
|
||||
|
||||
int currentLevel = ReachHelper.getReachUpgrade(player);
|
||||
int currentLevel = EffortlessBuildingClient.POWER_LEVEL.getPowerLevel(player);
|
||||
if (currentLevel == 0) {
|
||||
ReachHelper.setReachUpgrade(player, 1);
|
||||
EffortlessBuildingClient.POWER_LEVEL.setPowerLevel(player, 1);
|
||||
|
||||
if (world.isClientSide) EffortlessBuilding.log(player, "Upgraded reach to " + ReachHelper.getMaxReach(player));
|
||||
if (world.isClientSide) EffortlessBuilding.log(player, "Upgraded reach to " + EffortlessBuildingClient.POWER_LEVEL.getMaxReach(player));
|
||||
player.setItemInHand(hand, ItemStack.EMPTY);
|
||||
|
||||
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("entity.player.levelup"));
|
||||
player.playSound(soundEvent, 1f, 1f);
|
||||
} else if (currentLevel > 0) {
|
||||
if (world.isClientSide)
|
||||
EffortlessBuilding.log(player, "Already used this upgrade! Current reach is " + ReachHelper
|
||||
EffortlessBuilding.log(player, "Already used this upgrade! Current reach is " + EffortlessBuildingClient.POWER_LEVEL
|
||||
.getMaxReach(player) + ".");
|
||||
|
||||
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather"));
|
||||
@@ -61,7 +61,7 @@ public class ReachUpgrade1Item extends Item {
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag flag) {
|
||||
tooltip.add(Component.literal(ChatFormatting.GRAY + "Consume to increase reach to " + ChatFormatting.BLUE + CommonConfig.reach.reachLevel1.get()));
|
||||
tooltip.add(Component.literal(ChatFormatting.GRAY + "Consume to increase reach to " + ChatFormatting.BLUE + CommonConfig.reach.level1.get()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.world.level.Level;
|
||||
import nl.requios.effortlessbuilding.CommonConfig;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.utilities.ReachHelper;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -39,11 +39,11 @@ public class ReachUpgrade2Item extends Item {
|
||||
return new InteractionResultHolder<>(InteractionResult.PASS, player.getItemInHand(hand));
|
||||
}
|
||||
|
||||
int currentLevel = ReachHelper.getReachUpgrade(player);
|
||||
int currentLevel = EffortlessBuildingClient.POWER_LEVEL.getPowerLevel(player);
|
||||
if (currentLevel == 1) {
|
||||
ReachHelper.setReachUpgrade(player, 2);
|
||||
EffortlessBuildingClient.POWER_LEVEL.setPowerLevel(player, 2);
|
||||
|
||||
if (world.isClientSide) EffortlessBuilding.log(player, "Upgraded reach to " + ReachHelper.getMaxReach(player));
|
||||
if (world.isClientSide) EffortlessBuilding.log(player, "Upgraded reach to " + EffortlessBuildingClient.POWER_LEVEL.getMaxReach(player));
|
||||
player.setItemInHand(hand, ItemStack.EMPTY);
|
||||
|
||||
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("entity.player.levelup"));
|
||||
@@ -55,7 +55,7 @@ public class ReachUpgrade2Item extends Item {
|
||||
player.playSound(soundEvent, 1f, 1f);
|
||||
} else if (currentLevel > 1) {
|
||||
if (world.isClientSide)
|
||||
EffortlessBuilding.log(player, "Already used this upgrade! Current reach is " + ReachHelper
|
||||
EffortlessBuilding.log(player, "Already used this upgrade! Current reach is " + EffortlessBuildingClient.POWER_LEVEL
|
||||
.getMaxReach(player) + ".");
|
||||
|
||||
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather"));
|
||||
@@ -66,7 +66,7 @@ public class ReachUpgrade2Item extends Item {
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag flag) {
|
||||
tooltip.add(Component.literal(ChatFormatting.GRAY + "Consume to increase reach to " + ChatFormatting.BLUE + CommonConfig.reach.reachLevel2.get()));
|
||||
tooltip.add(Component.literal(ChatFormatting.GRAY + "Consume to increase reach to " + ChatFormatting.BLUE + CommonConfig.reach.level2.get()));
|
||||
tooltip.add(Component.literal(ChatFormatting.GRAY + "Previous upgrades need to be consumed first"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.world.level.Level;
|
||||
import nl.requios.effortlessbuilding.CommonConfig;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.utilities.ReachHelper;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -39,11 +39,11 @@ public class ReachUpgrade3Item extends Item {
|
||||
return new InteractionResultHolder<>(InteractionResult.PASS, player.getItemInHand(hand));
|
||||
}
|
||||
|
||||
int currentLevel = ReachHelper.getReachUpgrade(player);
|
||||
int currentLevel = EffortlessBuildingClient.POWER_LEVEL.getPowerLevel(player);
|
||||
if (currentLevel == 2) {
|
||||
ReachHelper.setReachUpgrade(player, 3);
|
||||
EffortlessBuildingClient.POWER_LEVEL.setPowerLevel(player, 3);
|
||||
|
||||
if (world.isClientSide) EffortlessBuilding.log(player, "Upgraded reach to " + ReachHelper.getMaxReach(player));
|
||||
if (world.isClientSide) EffortlessBuilding.log(player, "Upgraded reach to " + EffortlessBuildingClient.POWER_LEVEL.getMaxReach(player));
|
||||
player.setItemInHand(hand, ItemStack.EMPTY);
|
||||
|
||||
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("entity.player.levelup"));
|
||||
@@ -58,7 +58,7 @@ public class ReachUpgrade3Item extends Item {
|
||||
player.playSound(soundEvent, 1f, 1f);
|
||||
} else if (currentLevel > 2) {
|
||||
if (world.isClientSide)
|
||||
EffortlessBuilding.log(player, "Already used this upgrade! Current reach is " + ReachHelper
|
||||
EffortlessBuilding.log(player, "Already used this upgrade! Current reach is " + EffortlessBuildingClient.POWER_LEVEL
|
||||
.getMaxReach(player) + ".");
|
||||
|
||||
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather"));
|
||||
@@ -69,7 +69,7 @@ public class ReachUpgrade3Item extends Item {
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag flag) {
|
||||
tooltip.add(Component.literal(ChatFormatting.GRAY + "Consume to increase reach to " + ChatFormatting.BLUE + CommonConfig.reach.reachLevel3.get()));
|
||||
tooltip.add(Component.literal(ChatFormatting.GRAY + "Consume to increase reach to " + ChatFormatting.BLUE + CommonConfig.reach.level3.get()));
|
||||
tooltip.add(Component.literal(ChatFormatting.GRAY + "Previous upgrades need to be consumed first"));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package nl.requios.effortlessbuilding.systems;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
import nl.requios.effortlessbuilding.network.IsQuickReplacingPacket;
|
||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||
@@ -66,7 +67,7 @@ public class BuildSettings {
|
||||
return getReplaceMode() != ReplaceMode.ONLY_AIR;
|
||||
}
|
||||
|
||||
public boolean canReplaceBlocks(){
|
||||
private boolean canReplaceBlocks(){
|
||||
return Minecraft.getInstance().player != null && PowerLevel.canReplaceBlocks(Minecraft.getInstance().player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class BuilderChain {
|
||||
|
||||
if (!blocks.isEmpty()) {
|
||||
EffortlessBuildingClient.BLOCK_PREVIEWS.onBlocksPlaced(blocks);
|
||||
BlockUtilities.playSoundIfFurtherThanNormal(player, blocks.getLastBlockEntry(), false);
|
||||
ClientBlockUtilities.playSoundIfFurtherThanNormal(player, blocks.getLastBlockEntry(), false);
|
||||
player.swing(InteractionHand.MAIN_HAND);
|
||||
|
||||
blocks.skipFirst = buildMode == BuildModeEnum.DISABLED;
|
||||
@@ -103,7 +103,7 @@ public class BuilderChain {
|
||||
}
|
||||
|
||||
var player = Minecraft.getInstance().player;
|
||||
if (!ReachHelper.canBreakFar(player)) return;
|
||||
if (player != null && !PowerLevel.canBreakFar(player)) return;
|
||||
|
||||
if (buildingState == BuildingState.IDLE){
|
||||
buildingState = BuildingState.BREAKING;
|
||||
@@ -124,7 +124,7 @@ public class BuilderChain {
|
||||
|
||||
if (!blocks.isEmpty()) {
|
||||
EffortlessBuildingClient.BLOCK_PREVIEWS.onBlocksBroken(blocks);
|
||||
BlockUtilities.playSoundIfFurtherThanNormal(player, blocks.getLastBlockEntry(), true);
|
||||
ClientBlockUtilities.playSoundIfFurtherThanNormal(player, blocks.getLastBlockEntry(), true);
|
||||
player.swing(InteractionHand.MAIN_HAND);
|
||||
blocks.skipFirst = buildMode == BuildModeEnum.DISABLED;
|
||||
PacketHandler.INSTANCE.sendToServer(new ServerBreakBlocksPacket(blocks));
|
||||
@@ -194,7 +194,7 @@ public class BuilderChain {
|
||||
|
||||
var itemStack = player.getItemInHand(InteractionHand.MAIN_HAND);
|
||||
boolean blockInHand = CompatHelper.isItemBlockProxy(itemStack);
|
||||
boolean lookingAtInteractiveObject = BlockUtilities.determineIfLookingAtInteractiveObject(mc, world);
|
||||
boolean lookingAtInteractiveObject = ClientBlockUtilities.determineIfLookingAtInteractiveObject(mc, world);
|
||||
boolean isShiftKeyDown = player.isShiftKeyDown();
|
||||
|
||||
if (lookingAtInteractiveObject && !isShiftKeyDown)
|
||||
@@ -213,14 +213,14 @@ public class BuilderChain {
|
||||
if (shouldLookAtNear) {
|
||||
lookingAt = lookingAtNear;
|
||||
} else {
|
||||
lookingAt = BlockUtilities.getLookingAtFar(player);
|
||||
lookingAt = ClientBlockUtilities.getLookingAtFar(player);
|
||||
}
|
||||
if (lookingAt == null || lookingAt.getType() == HitResult.Type.MISS) return null;
|
||||
|
||||
var startPos = lookingAt.getBlockPos();
|
||||
|
||||
//Check if out of reach
|
||||
int maxReach = ReachHelper.getMaxReach(player);
|
||||
int maxReach = EffortlessBuildingClient.POWER_LEVEL.getMaxReach(player);
|
||||
if (player.blockPosition().distSqr(startPos) > maxReach * maxReach) return null;
|
||||
|
||||
startPosForBreaking = startPos;
|
||||
@@ -240,7 +240,7 @@ public class BuilderChain {
|
||||
//We can only break
|
||||
|
||||
//Do not break far if we are not allowed to
|
||||
if (!shouldLookAtNear && !ReachHelper.canBreakFar(player)) return null;
|
||||
if (!shouldLookAtNear && !PowerLevel.canBreakFar(player)) return null;
|
||||
}
|
||||
|
||||
var blockEntry = new BlockEntry(startPos);
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
package nl.requios.effortlessbuilding.systems;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.util.Mth;
|
||||
import nl.requios.effortlessbuilding.CommonConfig;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
|
||||
//Common
|
||||
public class PowerLevel {
|
||||
private static final String POWER_LEVEL_KEY = EffortlessBuilding.MODID + ":powerLevel";
|
||||
private static final int MAX_POWER_LEVEL = 3;
|
||||
|
||||
public int getPowerLevel(Player player) {
|
||||
if (!player.getPersistentData().contains(POWER_LEVEL_KEY)) return 0;
|
||||
return player.getPersistentData().getInt(POWER_LEVEL_KEY);
|
||||
}
|
||||
|
||||
public void increasePowerLevel(Player player) {
|
||||
int powerLevel = getPowerLevel(player);
|
||||
if (powerLevel < MAX_POWER_LEVEL) {
|
||||
setPowerLevel(player, powerLevel + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPowerLevel(Player player, int powerLevel) {
|
||||
player.getPersistentData().putInt(POWER_LEVEL_KEY, powerLevel);
|
||||
|
||||
if (player.level.isClientSide) {
|
||||
EffortlessBuildingClient.BUILD_MODIFIERS.onPowerLevelChanged(powerLevel);
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxReach(Player player) {
|
||||
if (player.isCreative()) return CommonConfig.reach.creative.get();
|
||||
return switch (getPowerLevel(player)) {
|
||||
case 1 -> CommonConfig.reach.level1.get();
|
||||
case 2 -> CommonConfig.reach.level2.get();
|
||||
case 3 -> CommonConfig.reach.level3.get();
|
||||
default -> CommonConfig.reach.level0.get();
|
||||
};
|
||||
}
|
||||
|
||||
public int getPlacementReach(Player player) {
|
||||
if (player.isCreative()) return CommonConfig.reach.creative.get();
|
||||
return switch (getPowerLevel(player)) {
|
||||
case 1 -> CommonConfig.reach.level1.get();
|
||||
case 2 -> CommonConfig.reach.level2.get();
|
||||
case 3 -> CommonConfig.reach.level3.get();
|
||||
default -> CommonConfig.reach.level0.get();
|
||||
};
|
||||
}
|
||||
|
||||
//How far away we can detect the second and third click of build modes (distance to player)
|
||||
public int getBuildModeReach(Player player) {
|
||||
//A bit further than placement reach, so you can build lines when looking to the side without having to move.
|
||||
return getMaxReach(player) + 6;
|
||||
}
|
||||
|
||||
public int getMaxBlocksPlacedAtOnce(Player player) {
|
||||
if (player.isCreative()) return CommonConfig.maxBlocksPlacedAtOnce.creative.get();
|
||||
return switch (getPowerLevel(player)) {
|
||||
case 1 -> CommonConfig.maxBlocksPlacedAtOnce.level1.get();
|
||||
case 2 -> CommonConfig.maxBlocksPlacedAtOnce.level2.get();
|
||||
case 3 -> CommonConfig.maxBlocksPlacedAtOnce.level3.get();
|
||||
default -> CommonConfig.maxBlocksPlacedAtOnce.level0.get();
|
||||
};
|
||||
}
|
||||
|
||||
public int getMaxBlocksPerAxis(Player player) {
|
||||
if (player.isCreative()) return CommonConfig.maxBlocksPerAxis.creative.get();
|
||||
return switch (getPowerLevel(player)) {
|
||||
case 1 -> CommonConfig.maxBlocksPerAxis.level1.get();
|
||||
case 2 -> CommonConfig.maxBlocksPerAxis.level2.get();
|
||||
case 3 -> CommonConfig.maxBlocksPerAxis.level3.get();
|
||||
default -> CommonConfig.maxBlocksPerAxis.level0.get();
|
||||
};
|
||||
}
|
||||
|
||||
public int getMaxMirrorRadius(Player player) {
|
||||
if (player.isCreative()) return CommonConfig.maxMirrorRadius.creative.get();
|
||||
return switch (getPowerLevel(player)) {
|
||||
case 1 -> CommonConfig.maxMirrorRadius.level1.get();
|
||||
case 2 -> CommonConfig.maxMirrorRadius.level2.get();
|
||||
case 3 -> CommonConfig.maxMirrorRadius.level3.get();
|
||||
default -> CommonConfig.maxMirrorRadius.level0.get();
|
||||
};
|
||||
}
|
||||
|
||||
public boolean isDisabled(Player player) {
|
||||
return getMaxBlocksPlacedAtOnce(player) <= 0 || getMaxBlocksPerAxis(player) <= 0;
|
||||
}
|
||||
|
||||
//Static methods are used by client and server
|
||||
public static boolean canBreakFar(Player player) {
|
||||
return player.isCreative();
|
||||
}
|
||||
|
||||
public static boolean canReplaceBlocks(Player player) {
|
||||
return player.isCreative();
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -101,7 +103,7 @@ public class BlockSet extends HashMap<BlockPos, BlockEntry> implements Iterable<
|
||||
public static class ClientSide {
|
||||
public static boolean isFull(BlockSet blockSet) {
|
||||
//Limit number of blocks you can place
|
||||
int limit = ReachHelper.getMaxBlocksPlacedAtOnce(net.minecraft.client.Minecraft.getInstance().player);
|
||||
int limit = EffortlessBuildingClient.POWER_LEVEL.getMaxBlocksPlacedAtOnce(net.minecraft.client.Minecraft.getInstance().player);
|
||||
if (blockSet.size() >= limit) {
|
||||
if (logging) EffortlessBuilding.log("BlockSet limit reached, not adding block.");
|
||||
return true;
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
package nl.requios.effortlessbuilding.utilities;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.Half;
|
||||
import net.minecraft.world.level.block.state.properties.SlabType;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
|
||||
//Common
|
||||
public class BlockUtilities {
|
||||
@@ -34,36 +27,6 @@ public class BlockUtilities {
|
||||
return block.getStateForPlacement(new BlockPlaceContext(player, hand, blockItemStack, blockHitResult));
|
||||
}
|
||||
|
||||
public static boolean determineIfLookingAtInteractiveObject(Minecraft mc, Level level) {
|
||||
//Check if we are looking at an interactive object
|
||||
var result = false;
|
||||
if (mc.hitResult != null) {
|
||||
if (mc.hitResult.getType() == HitResult.Type.BLOCK) {
|
||||
var blockHitResult = (BlockHitResult) mc.hitResult;
|
||||
var blockState = level.getBlockState(blockHitResult.getBlockPos());
|
||||
if (blockState.hasBlockEntity()) {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
if (mc.hitResult.getType() == HitResult.Type.ENTITY) {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void playSoundIfFurtherThanNormal(Player player, BlockEntry blockEntry, boolean breaking) {
|
||||
|
||||
if (Minecraft.getInstance().hitResult != null && Minecraft.getInstance().hitResult.getType() == HitResult.Type.BLOCK)
|
||||
return;
|
||||
|
||||
if (blockEntry == null || blockEntry.newBlockState == null)
|
||||
return;
|
||||
|
||||
SoundType soundType = blockEntry.newBlockState.getBlock().getSoundType(blockEntry.newBlockState, player.level, blockEntry.blockPos, player);
|
||||
SoundEvent soundEvent = breaking ? soundType.getBreakSound() : soundType.getPlaceSound();
|
||||
player.level.playSound(player, player.blockPosition(), soundEvent, SoundSource.BLOCKS, 0.6f, soundType.getPitch());
|
||||
}
|
||||
|
||||
public static BlockState getVerticalMirror(BlockState blockState) {
|
||||
//Stairs
|
||||
@@ -107,16 +70,4 @@ public class BlockUtilities {
|
||||
return blockState;
|
||||
}
|
||||
|
||||
public static BlockHitResult getLookingAtFar(Player player) {
|
||||
Level world = player.level;
|
||||
|
||||
//base distance off of player ability (config)
|
||||
float raytraceRange = ReachHelper.getPlacementReach(player);
|
||||
|
||||
Vec3 look = player.getLookAngle();
|
||||
Vec3 start = new Vec3(player.getX(), player.getY() + player.getEyeHeight(), player.getZ());
|
||||
Vec3 end = new Vec3(player.getX() + look.x * raytraceRange, player.getY() + player.getEyeHeight() + look.y * raytraceRange, player.getZ() + look.z * raytraceRange);
|
||||
|
||||
return world.clip(new ClipContext(start, end, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, player));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package nl.requios.effortlessbuilding.utilities;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ClientBlockUtilities {
|
||||
|
||||
public static boolean determineIfLookingAtInteractiveObject(Minecraft mc, Level level) {
|
||||
//Check if we are looking at an interactive object
|
||||
var result = false;
|
||||
if (mc.hitResult != null) {
|
||||
if (mc.hitResult.getType() == HitResult.Type.BLOCK) {
|
||||
var blockHitResult = (BlockHitResult) mc.hitResult;
|
||||
var blockState = level.getBlockState(blockHitResult.getBlockPos());
|
||||
if (blockState.hasBlockEntity()) {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
if (mc.hitResult.getType() == HitResult.Type.ENTITY) {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void playSoundIfFurtherThanNormal(Player player, BlockEntry blockEntry, boolean breaking) {
|
||||
|
||||
if (Minecraft.getInstance().hitResult != null && Minecraft.getInstance().hitResult.getType() == HitResult.Type.BLOCK)
|
||||
return;
|
||||
|
||||
if (blockEntry == null || blockEntry.newBlockState == null)
|
||||
return;
|
||||
|
||||
SoundType soundType = blockEntry.newBlockState.getBlock().getSoundType(blockEntry.newBlockState, player.level, blockEntry.blockPos, player);
|
||||
SoundEvent soundEvent = breaking ? soundType.getBreakSound() : soundType.getPlaceSound();
|
||||
player.level.playSound(player, player.blockPosition(), soundEvent, SoundSource.BLOCKS, 0.6f, soundType.getPitch());
|
||||
}
|
||||
|
||||
public static BlockHitResult getLookingAtFar(Player player) {
|
||||
Level world = player.level;
|
||||
|
||||
//base distance off of player ability (config)
|
||||
float raytraceRange = EffortlessBuildingClient.POWER_LEVEL.getPlacementReach(player);
|
||||
|
||||
Vec3 look = player.getLookAngle();
|
||||
Vec3 start = new Vec3(player.getX(), player.getY() + player.getEyeHeight(), player.getZ());
|
||||
Vec3 end = new Vec3(player.getX() + look.x * raytraceRange, player.getY() + player.getEyeHeight() + look.y * raytraceRange, player.getZ() + look.z * raytraceRange);
|
||||
|
||||
return world.clip(new ClipContext(start, end, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, player));
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.utilities;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.util.Mth;
|
||||
import nl.requios.effortlessbuilding.CommonConfig;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
|
||||
//Common
|
||||
public class ReachHelper {
|
||||
private static final String REACH_UPGRADE_KEY = EffortlessBuilding.MODID + ":reachUpgrade";
|
||||
|
||||
public static int getReachUpgrade(Player player) {
|
||||
if (!player.getPersistentData().contains(REACH_UPGRADE_KEY)) return 0;
|
||||
return player.getPersistentData().getInt(REACH_UPGRADE_KEY);
|
||||
}
|
||||
|
||||
//Remember that to actually save it, this needs to be called on the server
|
||||
public static void setReachUpgrade(Player player, int reachUpgrade) {
|
||||
player.getPersistentData().putInt(REACH_UPGRADE_KEY, reachUpgrade);
|
||||
|
||||
if (player.level.isClientSide) {
|
||||
//Set mirror radius to max
|
||||
int reach = 10;
|
||||
switch (reachUpgrade) {
|
||||
case 0:
|
||||
reach = CommonConfig.reach.maxReachLevel0.get();
|
||||
break;
|
||||
case 1:
|
||||
reach = CommonConfig.reach.maxReachLevel1.get();
|
||||
break;
|
||||
case 2:
|
||||
reach = CommonConfig.reach.maxReachLevel2.get();
|
||||
break;
|
||||
case 3:
|
||||
reach = CommonConfig.reach.maxReachLevel3.get();
|
||||
break;
|
||||
}
|
||||
|
||||
//TODO enable
|
||||
// if (this.mirrorSettings != null)
|
||||
// this.mirrorSettings.radius = reach / 2;
|
||||
// if (this.radialMirrorSettings != null)
|
||||
// this.radialMirrorSettings.radius = reach / 2;
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static int getMaxReach(Player player) {
|
||||
if (player.isCreative()) return CommonConfig.reach.maxReachCreative.get();
|
||||
|
||||
if (!CommonConfig.reach.enableReachUpgrades.get()) return CommonConfig.reach.maxReachLevel3.get();
|
||||
|
||||
return switch (getReachUpgrade(player)) {
|
||||
case 1 -> CommonConfig.reach.maxReachLevel1.get();
|
||||
case 2 -> CommonConfig.reach.maxReachLevel2.get();
|
||||
case 3 -> CommonConfig.reach.maxReachLevel3.get();
|
||||
default -> CommonConfig.reach.maxReachLevel0.get();
|
||||
};
|
||||
}
|
||||
|
||||
public static int getMaxMirrorRadius(Player player) {
|
||||
return getMaxReach(player) / 2;
|
||||
}
|
||||
|
||||
public static int getPlacementReach(Player player) {
|
||||
return getMaxReach(player) / 4;
|
||||
}
|
||||
|
||||
public static int getMaxBlocksPlacedAtOnce(Player player) {
|
||||
if (player.isCreative()) return 1000000;
|
||||
return Mth.ceil(Math.pow(getMaxReach(player), 1.6));
|
||||
//Level 0: 121
|
||||
//Level 1: 523
|
||||
//Level 2: 1585
|
||||
//Level 3: 4805
|
||||
}
|
||||
|
||||
public static int getMaxBlocksPerAxis(Player player) {
|
||||
if (player.isCreative()) return 2000;
|
||||
return Mth.ceil(getMaxReach(player) * 0.3);
|
||||
//Level 0: 6
|
||||
//Level 1: 15
|
||||
//Level 2: 30
|
||||
//Level 3: 60
|
||||
}
|
||||
|
||||
public static boolean canBreakFar(Player player) {
|
||||
return player.isCreative();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 414 B |
Binary file not shown.
|
After Width: | Height: | Size: 383 B |
Binary file not shown.
|
After Width: | Height: | Size: 325 B |
Reference in New Issue
Block a user