-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: use the declaring class to access fields in child class #10
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,8 +120,8 @@ void cleanupNeighbours() { | |
} | ||
|
||
boolean isValidChestNeighbor(BlockPos owner, BlockPos bp) { | ||
BlockState bs = client.world.getBlockState(bp); | ||
BlockState bs1 = client.world.getBlockState(owner); | ||
BlockState bs = Module.client.world.getBlockState(bp); | ||
BlockState bs1 = Module.client.world.getBlockState(owner); | ||
return bs1.getBlock() == bs.getBlock(); | ||
} | ||
Comment on lines
122
to
126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function |
||
|
||
|
@@ -134,7 +134,7 @@ void send(PacketEvent.Sent pe) { | |
if (childrenMap.values().stream().anyMatch(blockPos -> blockPos.contains(lastPos))) { | ||
return; // already part of another chest | ||
} | ||
BlockState bs = client.world.getBlockState(lastPos); | ||
BlockState bs = Module.client.world.getBlockState(lastPos); | ||
Block block = bs.getBlock(); | ||
List<Block> blocks = Arrays.asList(ALLOW_LIST); | ||
if (blocks.contains(block)) { | ||
Comment on lines
134
to
140
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function |
||
|
@@ -155,7 +155,7 @@ void send(PacketEvent.Sent pe) { | |
int x = (int) (-Math.round(Math.sin(v1))); | ||
int z = (int) Math.round(Math.cos(v1)); | ||
BlockPos secondPos = lastPos.add(x, 0, z); | ||
BlockState bs1 = client.world.getBlockState(secondPos); | ||
BlockState bs1 = Module.client.world.getBlockState(secondPos); | ||
if (bs1.getBlock() == block && bs1.get(ChestBlock.CHEST_TYPE) == chestType.getOpposite() && bs1.get(ChestBlock.FACING) == direction) { | ||
stacks.remove(secondPos); // if the neighbour was already indexed, remove him and use this pos instead | ||
childrenMap.computeIfAbsent(lastPos, blockPos -> new ArrayList<>()).add(secondPos); | ||
Comment on lines
155
to
161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function |
||
|
@@ -176,7 +176,7 @@ void send(PacketEvent.Sent pe) { | |
} | ||
this.stacks.putIfAbsent(this.currentPosClicked, new Int2ObjectArrayMap<>()); | ||
Int2ObjectMap<ItemStack> itemStackInt2ObjectMap = this.stacks.get(this.currentPosClicked); | ||
DefaultedList<Slot> slots = client.player.currentScreenHandler.slots; | ||
DefaultedList<Slot> slots = Module.client.player.currentScreenHandler.slots; | ||
int contentLength = slots.size() - 9 * 4; // this one includes the actual inventory so we remove it from the index | ||
for (int i = 0; i < contentLength; i++) { | ||
Slot slot = slots.get(i); | ||
Comment on lines
176
to
182
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function |
||
|
@@ -194,10 +194,10 @@ void send(PacketEvent.Sent pe) { | |
public void tick() { | ||
if (updateTimer.hasExpired(5_000)) { | ||
for (BlockPos blockPos : new ArrayList<>(stacks.keySet())) { | ||
if (!blockPos.isWithinDistance(client.player.getBlockPos(), 64)) { | ||
if (!blockPos.isWithinDistance(Module.client.player.getBlockPos(), 64)) { | ||
continue; // dont update this one we have no fucking idea whats in it | ||
} | ||
BlockState bs = client.world.getBlockState(blockPos); | ||
BlockState bs = Module.client.world.getBlockState(blockPos); | ||
if (!Arrays.asList(ALLOW_LIST).contains(bs.getBlock())) { | ||
stacks.remove(blockPos); | ||
} | ||
Comment on lines
194
to
203
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function |
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -49,15 +49,15 @@ void onPacket(coffee.client.helper.event.impl.PacketEvent.Sent event) { | |||||||||||||
|
||||||||||||||
@Override | ||||||||||||||
public void tick() { | ||||||||||||||
if (client.player == null || client.getNetworkHandler() == null) { | ||||||||||||||
if (Module.client.player == null || client.getNetworkHandler() == null) { | ||||||||||||||
return; | ||||||||||||||
} | ||||||||||||||
Comment on lines
+52
to
54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The check for - if (Module.client.player == null || client.getNetworkHandler() == null) {
+ if (Module.client.player == null || Module.client.getNetworkHandler() == null) { 57: - case Packet -> client.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(true));
+ case Packet -> Module.client.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(true)); Commitable suggestion (Beta)
Suggested change
[ISSUE][REFINE] 57: - case Packet -> client.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(true));
+ case Packet -> Module.client.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(true)); [ISSUE][REFINE] |
||||||||||||||
if (client.player.fallDistance > fallDist.getValue()) { | ||||||||||||||
if (Module.client.player.fallDistance > fallDist.getValue()) { | ||||||||||||||
switch (mode.getValue()) { | ||||||||||||||
case Packet -> client.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(true)); | ||||||||||||||
case BreakFall -> { | ||||||||||||||
client.player.setVelocity(0, 0.1, 0); | ||||||||||||||
client.player.fallDistance = 0; | ||||||||||||||
Module.client.player.setVelocity(0, 0.1, 0); | ||||||||||||||
Module.client.player.fallDistance = 0; | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -47,8 +47,8 @@ void iterateOverRange(double range, Consumer<Vec3d> positionsOffset) { | |||||||||||||||||||||||||||||||||
for (double y = -halfRange; y <= halfRange + 1; y++) { | ||||||||||||||||||||||||||||||||||
for (double z = -halfRange; z <= halfRange + 1; z++) { | ||||||||||||||||||||||||||||||||||
Vec3d posOff = new Vec3d(x - .5, y, z - .5); | ||||||||||||||||||||||||||||||||||
Vec3d actual = client.player.getPos().add(posOff); | ||||||||||||||||||||||||||||||||||
if (actual.distanceTo(client.player.getEyePos()) > range) { | ||||||||||||||||||||||||||||||||||
Vec3d actual = Module.client.player.getPos().add(posOff); | ||||||||||||||||||||||||||||||||||
if (actual.distanceTo(Module.client.player.getEyePos()) > range) { | ||||||||||||||||||||||||||||||||||
continue; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
positionsOffset.accept(actual); | ||||||||||||||||||||||||||||||||||
|
@@ -60,7 +60,7 @@ void iterateOverRange(double range, Consumer<Vec3d> positionsOffset) { | |||||||||||||||||||||||||||||||||
@Override | ||||||||||||||||||||||||||||||||||
public void tick() { | ||||||||||||||||||||||||||||||||||
switch (modeSetting.getValue()) { | ||||||||||||||||||||||||||||||||||
case Packet -> iterateOverRange(client.interactionManager.getReachDistance(), vec3d -> { | ||||||||||||||||||||||||||||||||||
case Packet -> iterateOverRange(Module.client.interactionManager.getReachDistance(), vec3d -> { | ||||||||||||||||||||||||||||||||||
BlockPos bp = new BlockPos(BlockPos.ofFloored(vec3d)); | ||||||||||||||||||||||||||||||||||
BlockState bs = client.world.getBlockState(bp); | ||||||||||||||||||||||||||||||||||
if (bs.isAir()) { | ||||||||||||||||||||||||||||||||||
Comment on lines
60
to
66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The - BlockState bs = client.world.getBlockState(bp);
+ BlockState bs = Module.client.world.getBlockState(bp); Commitable suggestion (Beta)
Suggested change
|
||||||||||||||||||||||||||||||||||
|
@@ -78,7 +78,7 @@ public void tick() { | |||||||||||||||||||||||||||||||||
new Vec3d(1, 1, 1), | ||||||||||||||||||||||||||||||||||
500); | ||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||
case Griefing -> iterateOverRange(client.interactionManager.getReachDistance(), vec3d -> { | ||||||||||||||||||||||||||||||||||
case Griefing -> iterateOverRange(Module.client.interactionManager.getReachDistance(), vec3d -> { | ||||||||||||||||||||||||||||||||||
BlockPos bp = new BlockPos(BlockPos.ofFloored(vec3d)); | ||||||||||||||||||||||||||||||||||
BlockState bs = client.world.getBlockState(bp); | ||||||||||||||||||||||||||||||||||
if (bs.isAir()) { | ||||||||||||||||||||||||||||||||||
Comment on lines
78
to
84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the previous hunk, - BlockState bs = client.world.getBlockState(bp);
+ BlockState bs = Module.client.world.getBlockState(bp); Commitable suggestion (Beta)
Suggested change
|
||||||||||||||||||||||||||||||||||
|
@@ -94,7 +94,7 @@ public void tick() { | |||||||||||||||||||||||||||||||||
500); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||
case Interaction -> iterateOverRange(client.interactionManager.getReachDistance(), vec3d -> { | ||||||||||||||||||||||||||||||||||
case Interaction -> iterateOverRange(Module.client.interactionManager.getReachDistance(), vec3d -> { | ||||||||||||||||||||||||||||||||||
BlockPos bp = new BlockPos(BlockPos.ofFloored(vec3d)); | ||||||||||||||||||||||||||||||||||
BlockState bs = client.world.getBlockState(bp); | ||||||||||||||||||||||||||||||||||
if (bs.isAir()) { | ||||||||||||||||||||||||||||||||||
Comment on lines
94
to
100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, - BlockState bs = client.world.getBlockState(bp);
+ BlockState bs = Module.client.world.getBlockState(bp); Commitable suggestion (Beta)
Suggested change
|
||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is repetitive and could be refactored to improve readability and maintainability. Consider creating a map of entity classes and their corresponding settings, then use a loop to check and interact with the entities. This would reduce the number of
if
statements and make the code easier to extend in the future.