Compare commits
8 Commits
151fd022c4
...
1.4.1
Author | SHA1 | Date | |
---|---|---|---|
d675832ecb | |||
a6f8645c68 | |||
2be7c16e8b | |||
ccbb15f7c4 | |||
05a93b5ab0 | |||
327c92a81c | |||
29067365ca | |||
1ae193ada7 |
43
README.md
43
README.md
@ -8,7 +8,6 @@ As a challenge I'm trying to make it as user-friendly as possible.
|
|||||||
|
|
||||||
## Server Side
|
## Server Side
|
||||||
|
|
||||||
### Features
|
|
||||||
- Custom join message
|
- Custom join message
|
||||||

|

|
||||||
- Custom quit message
|
- Custom quit message
|
||||||
@ -28,10 +27,15 @@ As a challenge I'm trying to make it as user-friendly as possible.
|
|||||||
- Shared EC Access control (via config)
|
- Shared EC Access control (via config)
|
||||||
- Open/close EC block while opening/closing SEC
|
- Open/close EC block while opening/closing SEC
|
||||||
- Play open & close sounds
|
- Play open & close sounds
|
||||||
- Vein miner
|
- Vein miner
|
||||||
|
- Configurable animation (tick delay)
|
||||||
|
- Leaves veinmineable using shears
|
||||||
Code inspired by Inferis!
|
Code inspired by Inferis!
|
||||||

|

|
||||||
- Chat Calculator
|
- Chat Calculator
|
||||||
|
- Check if operator is present before calculating
|
||||||
|
- Replenish
|
||||||
|
|
||||||
|
|
||||||
### Commands
|
### Commands
|
||||||
- /spectator | Essentially server-side free-cam, you get put in spectator and are able to fly around, once you use the command again you get put back to where you were.
|
- /spectator | Essentially server-side free-cam, you get put in spectator and are able to fly around, once you use the command again you get put back to where you were.
|
||||||
@ -44,37 +48,26 @@ Code inspired by Inferis!
|
|||||||

|

|
||||||
- Remove game fog (lava, water, etc.)
|
- Remove game fog (lava, water, etc.)
|
||||||
- All types individually toggleable
|
- All types individually toggleable
|
||||||
- Mod Menu integration
|
|
||||||
- Automatic config adaption (currently booleans only)
|
|
||||||
- Remove darkness effect
|
- Remove darkness effect
|
||||||
- Toggleable
|
- Toggleable
|
||||||
- Keybinding for /spectator
|
- Keybinding for /spectator
|
||||||
|
- Render block entities from a longer range
|
||||||
# Currently working on
|
- Toggleable via GUI
|
||||||
|
- Configurable value
|
||||||
## Server Side
|
- In GUI
|
||||||
- [x] Chat Calculator
|
- Mod Menu integration
|
||||||
- [x] Check if operator is present before calculating
|
DISCLAIMER: this is NOT perfect and still needs to be reworked, I'm just too lazy right now...
|
||||||
- Vein Miner
|
|
||||||
- [x] Configurable animation (tick delay)
|
|
||||||
- [x] Leaves veinmineable using shears
|
|
||||||
- [x] Replenish
|
|
||||||
|
|
||||||
|
|
||||||
## Client Side
|
|
||||||
|
|
||||||
- [x] Render block entities from a longer range
|
|
||||||
- [x] Toggleable via GUI
|
|
||||||
- [x] Configurable value
|
|
||||||
- [x] In GUI
|
|
||||||
- [x] Rework Mod Menu integration to be more flexible
|
|
||||||
- The following types are accepted:
|
- The following types are accepted:
|
||||||
- String
|
- String
|
||||||
- Boolean
|
- Boolean
|
||||||
- Float
|
- Float
|
||||||
- Integer
|
- Integer
|
||||||
- [x] Zoom
|
- Zoom
|
||||||
- [ ] Configurable
|
- Configurable
|
||||||
|
- Smooth zoom
|
||||||
|
- Initial zoom value
|
||||||
|
- Zoom step value
|
||||||
|
- Scroll to zoom further
|
||||||
|
|
||||||
# To-do
|
# To-do
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import net.fabricmc.api.ClientModInitializer;
|
|||||||
import wtf.hak.survivalfabric.config.client.ClientConfigManager;
|
import wtf.hak.survivalfabric.config.client.ClientConfigManager;
|
||||||
import wtf.hak.survivalfabric.features.AngleViewer;
|
import wtf.hak.survivalfabric.features.AngleViewer;
|
||||||
import wtf.hak.survivalfabric.features.RemoveDarknessEffect;
|
import wtf.hak.survivalfabric.features.RemoveDarknessEffect;
|
||||||
import wtf.hak.survivalfabric.features.SFKeyBindings;
|
import wtf.hak.survivalfabric.features.CameraShortcut;
|
||||||
import wtf.hak.survivalfabric.features.Zoom;
|
import wtf.hak.survivalfabric.features.Zoom;
|
||||||
|
|
||||||
public class SurvivalFabricClient implements ClientModInitializer {
|
public class SurvivalFabricClient implements ClientModInitializer {
|
||||||
@ -18,7 +18,7 @@ public class SurvivalFabricClient implements ClientModInitializer {
|
|||||||
// Features
|
// Features
|
||||||
AngleViewer.register();
|
AngleViewer.register();
|
||||||
RemoveDarknessEffect.register();
|
RemoveDarknessEffect.register();
|
||||||
SFKeyBindings.register();
|
CameraShortcut.register();
|
||||||
Zoom.register();
|
Zoom.register();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package wtf.hak.survivalfabric.config.client;
|
package wtf.hak.survivalfabric.config.client;
|
||||||
|
|
||||||
public class ClientConfig {
|
public class ClientConfig {
|
||||||
public String configVersion = "1.0";
|
public String configVersion = "1.1";
|
||||||
|
|
||||||
public boolean renderNetherFog = false;
|
public boolean renderNetherFog = false;
|
||||||
public boolean renderOverworldFog = false;
|
public boolean renderOverworldFog = false;
|
||||||
@ -13,4 +13,8 @@ public class ClientConfig {
|
|||||||
public boolean lockTeleportHeadMovement = true;
|
public boolean lockTeleportHeadMovement = true;
|
||||||
public boolean manipulateBlockEntityDistance = true;
|
public boolean manipulateBlockEntityDistance = true;
|
||||||
public int blockEntityRange = 512;
|
public int blockEntityRange = 512;
|
||||||
|
public boolean smoothCamera = true;
|
||||||
|
public float initialZoom = 20f;
|
||||||
|
public boolean scrollToZoom = true;
|
||||||
|
public float zoomStep = 2.5f;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import net.minecraft.client.option.KeyBinding;
|
|||||||
import net.minecraft.client.util.InputUtil;
|
import net.minecraft.client.util.InputUtil;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
public class SFKeyBindings {
|
public class CameraShortcut {
|
||||||
|
|
||||||
private static final KeyBinding CAMERA_BIND = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.survivalfabric.camera", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_PERIOD, "category.survivalfabric.survivalfabric"));
|
private static final KeyBinding CAMERA_BIND = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.survivalfabric.camera", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_PERIOD, "category.survivalfabric.survivalfabric"));
|
||||||
|
|
@ -7,24 +7,37 @@ import net.minecraft.client.option.KeyBinding;
|
|||||||
import net.minecraft.client.util.InputUtil;
|
import net.minecraft.client.util.InputUtil;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
|
|
||||||
|
import static wtf.hak.survivalfabric.config.client.ClientConfigManager.getConfig;
|
||||||
|
|
||||||
public class Zoom {
|
public class Zoom {
|
||||||
|
|
||||||
private static final KeyBinding ZOOM_BIND = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.survivalfabric.zoom", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_C, "category.survivalfabric.survivalfabric"));
|
private static final KeyBinding ZOOM_BIND = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.survivalfabric.zoom", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_C, "category.survivalfabric.survivalfabric"));
|
||||||
private static final float INITIAL_ZOOM = 20f;
|
|
||||||
|
|
||||||
private static boolean SHOULD_ZOOM = false;
|
private static boolean SHOULD_ZOOM = false;
|
||||||
private static float ZOOM_STEP_VALUE = 2.5f;
|
|
||||||
private static int ZOOM_STEP = 0;
|
private static int ZOOM_STEP = 0;
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private static boolean initialSmoothZoom;
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||||
if (ZOOM_BIND.isPressed())
|
|
||||||
|
if (ZOOM_BIND.isPressed() && !SHOULD_ZOOM) {
|
||||||
|
if(getConfig().smoothCamera) {
|
||||||
|
initialSmoothZoom = MinecraftClient.getInstance().options.smoothCameraEnabled;
|
||||||
|
MinecraftClient.getInstance().options.smoothCameraEnabled = true;
|
||||||
|
}
|
||||||
SHOULD_ZOOM = true;
|
SHOULD_ZOOM = true;
|
||||||
else {
|
} else if (!ZOOM_BIND.isPressed() && SHOULD_ZOOM) {
|
||||||
SHOULD_ZOOM = false;
|
SHOULD_ZOOM = false;
|
||||||
ZOOM_STEP = 0;
|
ZOOM_STEP = 0;
|
||||||
|
if(getConfig().smoothCamera) {
|
||||||
|
MinecraftClient.getInstance().options.smoothCameraEnabled = initialSmoothZoom;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +46,7 @@ public class Zoom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static float getZoomFov() {
|
public static float getZoomFov() {
|
||||||
return INITIAL_ZOOM - -ZOOM_STEP * ZOOM_STEP_VALUE;
|
return getConfig().initialZoom - -ZOOM_STEP * getConfig().zoomStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void modifyStep(int step) {
|
public static void modifyStep(int step) {
|
||||||
@ -42,9 +55,9 @@ public class Zoom {
|
|||||||
// Clamp the zoom level so the FOV stays within [1, 110]
|
// Clamp the zoom level so the FOV stays within [1, 110]
|
||||||
float zoomFov = getZoomFov();
|
float zoomFov = getZoomFov();
|
||||||
if (zoomFov < 1) {
|
if (zoomFov < 1) {
|
||||||
ZOOM_STEP = Math.round((1 - INITIAL_ZOOM) / ZOOM_STEP_VALUE) + 1;
|
ZOOM_STEP = Math.round((1 - getConfig().initialZoom) / getConfig().zoomStep) + 1;
|
||||||
} else if (zoomFov > 110) {
|
} else if (zoomFov > 110) {
|
||||||
ZOOM_STEP = Math.round((110 - INITIAL_ZOOM) / ZOOM_STEP_VALUE);
|
ZOOM_STEP = Math.round((110 - getConfig().initialZoom) / getConfig().zoomStep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import wtf.hak.survivalfabric.features.Zoom;
|
import wtf.hak.survivalfabric.features.Zoom;
|
||||||
|
|
||||||
|
import static wtf.hak.survivalfabric.config.client.ClientConfigManager.getConfig;
|
||||||
|
|
||||||
@Mixin(Mouse.class)
|
@Mixin(Mouse.class)
|
||||||
public class MouseMixin {
|
public class MouseMixin {
|
||||||
|
|
||||||
@ -16,7 +18,7 @@ public class MouseMixin {
|
|||||||
*/
|
*/
|
||||||
@Inject(method = "onMouseScroll", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "onMouseScroll", at = @At("HEAD"), cancellable = true)
|
||||||
private void onMouseScroll(long window, double horizontal, double vertical, CallbackInfo ci) {
|
private void onMouseScroll(long window, double horizontal, double vertical, CallbackInfo ci) {
|
||||||
if (Zoom.isZooming()) {
|
if (Zoom.isZooming() && getConfig().scrollToZoom) {
|
||||||
if (MinecraftClient.getInstance().player != null) {
|
if (MinecraftClient.getInstance().player != null) {
|
||||||
if (vertical > 0)
|
if (vertical > 0)
|
||||||
Zoom.modifyStep(-1);
|
Zoom.modifyStep(-1);
|
||||||
|
@ -13,7 +13,9 @@ import wtf.hak.survivalfabric.features.veinminer.VeinMinerSession;
|
|||||||
import wtf.hak.survivalfabric.utils.Scheduler;
|
import wtf.hak.survivalfabric.utils.Scheduler;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static wtf.hak.survivalfabric.SurvivalFabric.LOGGER;
|
import static wtf.hak.survivalfabric.SurvivalFabric.LOGGER;
|
||||||
import static wtf.hak.survivalfabric.config.ConfigManager.getConfig;
|
import static wtf.hak.survivalfabric.config.ConfigManager.getConfig;
|
||||||
@ -21,7 +23,6 @@ import static wtf.hak.survivalfabric.config.ConfigManager.getConfig;
|
|||||||
public class DrillBase implements Drill {
|
public class DrillBase implements Drill {
|
||||||
|
|
||||||
protected VeinMinerSession session;
|
protected VeinMinerSession session;
|
||||||
|
|
||||||
protected TagKey<Block> tag;
|
protected TagKey<Block> tag;
|
||||||
|
|
||||||
public DrillBase(VeinMinerSession session, TagKey<Block> tag) {
|
public DrillBase(VeinMinerSession session, TagKey<Block> tag) {
|
||||||
@ -36,11 +37,11 @@ public class DrillBase implements Drill {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean drill(BlockPos startPos) {
|
public boolean drill(BlockPos startPos) {
|
||||||
handleBlock(session.world.getBlockState(startPos).getBlock(), new ArrayList<>(), startPos, 0);
|
handleBlock(session.world.getBlockState(startPos).getBlock(), new HashSet<>(), startPos, 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleBlock(Block initialBlock, List<BlockPos> history, BlockPos pos, int brokenBlocks) {
|
private void handleBlock(Block initialBlock, Set<BlockPos> history, BlockPos pos, int brokenBlocks) {
|
||||||
if (brokenBlocks < getConfig().maxVeinSize) {
|
if (brokenBlocks < getConfig().maxVeinSize) {
|
||||||
history.add(pos);
|
history.add(pos);
|
||||||
if (tryBreakBlock(pos)) {
|
if (tryBreakBlock(pos)) {
|
||||||
@ -48,30 +49,40 @@ public class DrillBase implements Drill {
|
|||||||
int finalBrokenBlocks = brokenBlocks;
|
int finalBrokenBlocks = brokenBlocks;
|
||||||
|
|
||||||
// Put everything in a list to avoid scheduling a lot of tasks.
|
// Put everything in a list to avoid scheduling a lot of tasks.
|
||||||
// Has the added benefit of only playing one sound
|
Set<BlockPos> toBreak = new HashSet<>();
|
||||||
|
collectAdjacentBlocks(pos, history, initialBlock, toBreak);
|
||||||
List<BlockPos> toBreak = new ArrayList<>();
|
|
||||||
forXYZ(pos, 1, newPos -> {
|
|
||||||
if (!history.contains(newPos) && session.world.getBlockState(newPos).getBlock() == initialBlock) {
|
|
||||||
toBreak.add(newPos);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
long delay = getConfig().veinAnimationTicks;
|
long delay = getConfig().veinAnimationTicks;
|
||||||
if (delay <= 0)
|
|
||||||
for (BlockPos newPos : toBreak)
|
|
||||||
handleBlock(initialBlock, history, newPos, finalBrokenBlocks);
|
|
||||||
else {
|
|
||||||
Scheduler.get().scheduleTask(() -> {
|
|
||||||
for (BlockPos newPos : toBreak)
|
|
||||||
handleBlock(initialBlock, history, newPos, finalBrokenBlocks);
|
|
||||||
}, delay);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Use final or effectively final variables for lambda
|
||||||
|
final int[] finalBrokenBlocksArr = {finalBrokenBlocks};
|
||||||
|
|
||||||
|
if (delay <= 0) {
|
||||||
|
handleBlocksInBatch(toBreak, initialBlock, history, finalBrokenBlocksArr[0]);
|
||||||
|
} else {
|
||||||
|
Scheduler.get().scheduleTask(() -> handleBlocksInBatch(toBreak, initialBlock, history, finalBrokenBlocksArr[0]), delay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void collectAdjacentBlocks(BlockPos pos, Set<BlockPos> history, Block initialBlock, Set<BlockPos> toBreak) {
|
||||||
|
forXYZ(pos, 1, new ForXYZHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(BlockPos newPos) {
|
||||||
|
if (!history.contains(newPos) && session.world.getBlockState(newPos).getBlock() == initialBlock) {
|
||||||
|
toBreak.add(newPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleBlocksInBatch(Set<BlockPos> toBreak, Block initialBlock, Set<BlockPos> history, int finalBrokenBlocks) {
|
||||||
|
for (BlockPos newPos : toBreak) {
|
||||||
|
handleBlock(initialBlock, history, newPos, finalBrokenBlocks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRightTool(BlockPos pos) {
|
public boolean isRightTool(BlockPos pos) {
|
||||||
var blockState = session.world.getBlockState(pos);
|
var blockState = session.world.getBlockState(pos);
|
||||||
@ -79,9 +90,12 @@ public class DrillBase implements Drill {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void forXYZ(BlockPos pos, int max, ForXYZHandler handler) {
|
protected void forXYZ(BlockPos pos, int max, ForXYZHandler handler) {
|
||||||
forXYZ(pos, max, handlerPos -> {
|
forXYZ(pos, max, new ForXYZCounter() {
|
||||||
handler.handle(handlerPos);
|
@Override
|
||||||
return 0;
|
public int handle(BlockPos pos) {
|
||||||
|
handler.handle(pos);
|
||||||
|
return 1; // Accumulate one count for each position processed
|
||||||
|
}
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,14 +104,17 @@ public class DrillBase implements Drill {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void forXYZ(BlockPos pos, int max, ForXYZHandler handler, boolean forceVertical) {
|
protected void forXYZ(BlockPos pos, int max, ForXYZHandler handler, boolean forceVertical) {
|
||||||
forXYZ(pos, max, handlerPos -> {
|
forXYZ(pos, max, new ForXYZCounter() {
|
||||||
handler.handle(handlerPos);
|
@Override
|
||||||
return 0;
|
public int handle(BlockPos pos) {
|
||||||
|
handler.handle(pos);
|
||||||
|
return 1; // Accumulate one count for each position processed
|
||||||
|
}
|
||||||
}, forceVertical);
|
}, forceVertical);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int forXYZ(BlockPos pos, int max, ForXYZCounter handler, boolean forceVertical) {
|
protected int forXYZ(BlockPos pos, int max, ForXYZCounter handler, boolean forceVertical) {
|
||||||
ArrayList<Integer> offsets = new ArrayList<Integer>();
|
Set<Integer> offsets = new HashSet<>();
|
||||||
for (int d = 0; d <= max; ++d) {
|
for (int d = 0; d <= max; ++d) {
|
||||||
offsets.add(d);
|
offsets.add(d);
|
||||||
if (d != -d) {
|
if (d != -d) {
|
||||||
@ -105,39 +122,21 @@ public class DrillBase implements Drill {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] order = new String[]{"x", "y", "z"};
|
String[] order = determineOrder(forceVertical);
|
||||||
if (forceVertical) {
|
|
||||||
order = new String[]{"y", "x", "z"};
|
|
||||||
} else {
|
|
||||||
ServerPlayerEntity player = session.player;
|
|
||||||
boolean majorPitchChange = player.getPitch() < -45.0 || player.getPitch() > 45.0;
|
|
||||||
boolean majorYawChange = (player.getYaw() > 45.0 && player.getYaw() < 135.0) || (player.getYaw() < -45.0 && player.getYaw() > -135.0);
|
|
||||||
if (majorPitchChange) {
|
|
||||||
if (majorYawChange) {
|
|
||||||
order = new String[]{"y", "z", "x"};
|
|
||||||
} else {
|
|
||||||
order = new String[]{"y", "x", "z"};
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (majorYawChange) {
|
|
||||||
order = new String[]{"z", "y", "x"};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
|
||||||
for (int i1 : offsets) {
|
for (int i1 : offsets) {
|
||||||
for (int i2 : offsets) {
|
for (int i2 : offsets) {
|
||||||
for (int i3 : offsets) {
|
for (int i3 : offsets) {
|
||||||
int ix = order[0] == "x" ? i1 : order[1] == "x" ? i2 : i3;
|
int ix = order[0].equals("x") ? i1 : order[1].equals("x") ? i2 : i3;
|
||||||
int iy = order[0] == "y" ? i1 : order[1] == "y" ? i2 : i3;
|
int iy = order[0].equals("y") ? i1 : order[1].equals("y") ? i2 : i3;
|
||||||
int iz = order[0] == "z" ? i1 : order[1] == "z" ? i2 : i3;
|
int iz = order[0].equals("z") ? i1 : order[1].equals("z") ? i2 : i3;
|
||||||
|
|
||||||
int px = pos.getX() + ix;
|
int px = pos.getX() + ix;
|
||||||
int py = pos.getY() + iy;
|
int py = pos.getY() + iy;
|
||||||
int pz = pos.getZ() + iz;
|
int pz = pos.getZ() + iz;
|
||||||
|
|
||||||
counter += handler.handle(new BlockPos(px, py, pz));
|
counter += handler.handle(new BlockPos(px, py, pz)); // Works with ForXYZCounter, returning an int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,6 +144,29 @@ public class DrillBase implements Drill {
|
|||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String[] determineOrder(boolean forceVertical) {
|
||||||
|
if (forceVertical) {
|
||||||
|
return new String[]{"y", "x", "z"};
|
||||||
|
} else {
|
||||||
|
ServerPlayerEntity player = session.player;
|
||||||
|
boolean majorPitchChange = player.getPitch() < -45.0 || player.getPitch() > 45.0;
|
||||||
|
boolean majorYawChange = (player.getYaw() > 45.0 && player.getYaw() < 135.0) || (player.getYaw() < -45.0 && player.getYaw() > -135.0);
|
||||||
|
|
||||||
|
if (majorPitchChange) {
|
||||||
|
if (majorYawChange) {
|
||||||
|
return new String[]{"y", "z", "x"};
|
||||||
|
} else {
|
||||||
|
return new String[]{"y", "x", "z"};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (majorYawChange) {
|
||||||
|
return new String[]{"z", "y", "x"};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new String[]{"x", "y", "z"};
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean tryBreakBlock(BlockPos blockPos) {
|
protected boolean tryBreakBlock(BlockPos blockPos) {
|
||||||
session.addPosition(blockPos);
|
session.addPosition(blockPos);
|
||||||
boolean success = isRightTool(blockPos) && session.player.interactionManager.tryBreakBlock(blockPos);
|
boolean success = isRightTool(blockPos) && session.player.interactionManager.tryBreakBlock(blockPos);
|
||||||
@ -168,4 +190,4 @@ public class DrillBase implements Drill {
|
|||||||
protected interface ForXYZCounter {
|
protected interface ForXYZCounter {
|
||||||
int handle(BlockPos pos);
|
int handle(BlockPos pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,9 @@ package wtf.hak.survivalfabric.mixin;
|
|||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.CropBlock;
|
import net.minecraft.block.CropBlock;
|
||||||
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.HoeItem;
|
import net.minecraft.item.HoeItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
@ -39,9 +41,11 @@ public abstract class BlockMixin {
|
|||||||
for (ItemStack drop : drops) {
|
for (ItemStack drop : drops) {
|
||||||
Block.dropStack(world, pos, drop);
|
Block.dropStack(world, pos, drop);
|
||||||
}
|
}
|
||||||
|
player.incrementStat(Stats.USED.getOrCreateStat(seedItem));
|
||||||
|
mainHand.damage(1, player, EquipmentSlot.MAINHAND);
|
||||||
}
|
}
|
||||||
world.getServer().executeSync(() -> world.setBlockState(pos, seedBlock.getDefaultState()));
|
world.getServer().executeSync(() -> world.setBlockState(pos, seedBlock.getDefaultState()));
|
||||||
player.incrementStat(Stats.USED.getOrCreateStat(seedItem));
|
cir.setReturnValue(Blocks.AIR.getDefaultState());
|
||||||
cir.cancel();
|
cir.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user