Skip to content

Commit

Permalink
change: Update to Minecraft 1.16.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jellysquid3 committed Jun 24, 2020
1 parent df9bbea commit 0ee7055
Show file tree
Hide file tree
Showing 29 changed files with 133 additions and 261 deletions.
9 changes: 4 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=20w19a
yarn_mappings=20w19a+build.1
loader_version=0.8.2+build.194
minecraft_version=1.16.1
yarn_mappings=1.16.1+build.1
loader_version=0.8.8+build.202
# Mod Properties
mod_version=0.5.0
maven_group=me.jellysquid.mods
archives_base_name=lithium-fabric
cf_project_id=360438
cf_project_name=Lithium
cf_game_version=1.16-Snapshot

cf_game_version=1.16.1
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ static <T> Iterable<? extends T> cast(WeightedList<T> list) {
* @param <U> The value type stored in each list entry
*/
class ListIterator<U> implements Iterator<U> {
private final Iterator<WeightedList<U>.Entry<? extends U>> inner;
private final Iterator<WeightedList.Entry<? extends U>> inner;

public ListIterator(Iterator<WeightedList<U>.Entry<? extends U>> inner) {
public ListIterator(Iterator<WeightedList.Entry<? extends U>> inner) {
this.inner = inner;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ public static boolean isBoxFullyWithinWorldBorder(WorldBorder border, Box box) {
double wboxMaxX = Math.ceil(border.getBoundEast());
double wboxMaxZ = Math.ceil(border.getBoundSouth());

return box.x1 >= wboxMinX && box.x1 < wboxMaxX && box.z1 >= wboxMinZ && box.z1 < wboxMaxZ &&
box.x2 >= wboxMinX && box.x2 < wboxMaxX && box.z2 >= wboxMinZ && box.z2 < wboxMaxZ;
return box.minX >= wboxMinX && box.minX < wboxMaxX && box.minZ >= wboxMinZ && box.minZ < wboxMaxZ &&
box.maxX >= wboxMinX && box.maxX < wboxMaxX && box.maxZ >= wboxMinZ && box.maxZ < wboxMaxZ;
}

private static boolean canEntityCollideWithWorldBorder(CollisionView world, Entity entity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ public VoxelShape getCollidedShape() {
* with the {@param box}.
*/
private static CuboidBlockIterator createVolumeIteratorForCollision(Box box) {
int minX = MathHelper.floor(box.x1 - EPSILON) - 1;
int maxX = MathHelper.floor(box.x2 + EPSILON) + 1;
int minY = MathHelper.floor(box.y1 - EPSILON) - 1;
int maxY = MathHelper.floor(box.y2 + EPSILON) + 1;
int minZ = MathHelper.floor(box.z1 - EPSILON) - 1;
int maxZ = MathHelper.floor(box.z2 + EPSILON) + 1;
int minX = MathHelper.floor(box.minX - EPSILON) - 1;
int maxX = MathHelper.floor(box.maxX + EPSILON) + 1;
int minY = MathHelper.floor(box.minY - EPSILON) - 1;
int maxY = MathHelper.floor(box.maxY + EPSILON) + 1;
int minZ = MathHelper.floor(box.minZ - EPSILON) - 1;
int maxZ = MathHelper.floor(box.maxZ + EPSILON) + 1;

return new CuboidBlockIterator(minX, minY, minZ, maxX, maxY, maxZ);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ protected boolean contains(double x, double y, double z) {
}

@Override
public double getMinimum(Direction.Axis axis) {
public double getMin(Direction.Axis axis) {
return Double.POSITIVE_INFINITY;
}

@Override
public double getMaximum(Direction.Axis axis) {
public double getMax(Direction.Axis axis) {
return Double.NEGATIVE_INFINITY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@
public class VoxelShapeSimpleCube extends VoxelShape implements VoxelShapeExtended {
private static final double EPSILON = 1.0E-7D;

private final double x1, y1, z1, x2, y2, z2;
private final double minX, minY, minZ, maxX, maxY, maxZ;

public VoxelShapeSimpleCube(VoxelSet voxels, double x1, double y1, double z1, double x2, double y2, double z2) {
public VoxelShapeSimpleCube(VoxelSet voxels, double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
super(voxels);

this.x1 = x1;
this.y1 = y1;
this.z1 = z1;
this.x2 = x2;
this.y2 = y2;
this.z2 = z2;
this.minX = minX;
this.minY = minY;
this.minZ = minZ;
this.maxX = maxX;
this.maxY = maxY;
this.maxZ = maxZ;
}

@Override
public VoxelShape offset(double x, double y, double z) {
return new VoxelShapeSimpleCube(this.voxels, this.x1 + x, this.y1 + y, this.z1 + z, this.x2 + x, this.y2 + y, this.z2 + z);
return new VoxelShapeSimpleCube(this.voxels, this.minX + x, this.minY + y, this.minZ + z, this.maxX + x, this.maxY + y, this.maxZ + z);
}

@Override
Expand All @@ -59,11 +59,11 @@ public double calculateMaxDistance(AxisCycleDirection cycleDirection, Box box, d
private double calculatePenetration(AxisCycleDirection dir, Box box, double maxDist) {
switch (dir) {
case NONE:
return this.calculatePenetration(this.x1, this.x2, box.x1, box.x2, maxDist);
return this.calculatePenetration(this.minX, this.maxX, box.minX, box.maxX, maxDist);
case FORWARD:
return this.calculatePenetration(this.z1, this.z2, box.z1, box.z2, maxDist);
return this.calculatePenetration(this.minZ, this.maxZ, box.minZ, box.maxZ, maxDist);
case BACKWARD:
return this.calculatePenetration(this.y1, this.y2, box.y1, box.y2, maxDist);
return this.calculatePenetration(this.minY, this.maxY, box.minY, box.maxY, maxDist);
default:
throw new IllegalArgumentException();
}
Expand All @@ -72,11 +72,11 @@ private double calculatePenetration(AxisCycleDirection dir, Box box, double maxD
private boolean intersects(AxisCycleDirection dir, Box box) {
switch (dir) {
case NONE:
return lessThan(this.y1, box.y2) && lessThan(box.y1, this.y2) && lessThan(this.z1, box.z2) && lessThan(box.z1, this.z2);
return lessThan(this.minY, box.maxY) && lessThan(box.minY, this.maxY) && lessThan(this.minZ, box.maxZ) && lessThan(box.minZ, this.maxZ);
case FORWARD:
return lessThan(this.x1, box.x2) && lessThan(box.x1, this.x2) && lessThan(this.y1, box.y2) && lessThan(box.y1, this.y2);
return lessThan(this.minX, box.maxX) && lessThan(box.minX, this.maxX) && lessThan(this.minY, box.maxY) && lessThan(box.minY, this.maxY);
case BACKWARD:
return lessThan(this.z1, box.z2) && lessThan(box.z1, this.z2) && lessThan(this.x1, box.x2) && lessThan(box.x1, this.x2);
return lessThan(this.minZ, box.maxZ) && lessThan(box.minZ, this.maxZ) && lessThan(this.minX, box.maxX) && lessThan(box.minX, this.maxX);
default:
throw new IllegalArgumentException();
}
Expand Down Expand Up @@ -117,17 +117,17 @@ public List<Box> getBoundingBoxes() {

@Override
public Box getBoundingBox() {
return new Box(this.x1, this.y1, this.z1, this.x2, this.y2, this.z2);
return new Box(this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ);
}

@Override
public double getMinimum(Direction.Axis axis) {
return axis.choose(this.x1, this.y1, this.z1);
public double getMin(Direction.Axis axis) {
return axis.choose(this.minX, this.minY, this.minZ);
}

@Override
public double getMaximum(Direction.Axis axis) {
return axis.choose(this.x2, this.y2, this.z2);
public double getMax(Direction.Axis axis) {
return axis.choose(this.maxX, this.maxY, this.maxZ);
}

@Override
Expand All @@ -138,11 +138,11 @@ protected double getPointPosition(Direction.Axis axis, int index) {

switch (axis) {
case X:
return (index == 0) ? this.x1 : this.x2;
return (index == 0) ? this.minX : this.maxX;
case Y:
return (index == 0) ? this.y1 : this.y2;
return (index == 0) ? this.minY : this.maxY;
case Z:
return (index == 0) ? this.z1 : this.z2;
return (index == 0) ? this.minZ : this.maxZ;
}

throw new IllegalArgumentException();
Expand All @@ -152,33 +152,33 @@ protected double getPointPosition(Direction.Axis axis, int index) {
protected DoubleList getPointPositions(Direction.Axis axis) {
switch (axis) {
case X:
return DoubleArrayList.wrap(new double[]{this.x1, this.x2});
return DoubleArrayList.wrap(new double[]{this.minX, this.maxX});
case Y:
return DoubleArrayList.wrap(new double[]{this.y1, this.y2});
return DoubleArrayList.wrap(new double[]{this.minY, this.maxY});
case Z:
return DoubleArrayList.wrap(new double[]{this.z1, this.z2});
return DoubleArrayList.wrap(new double[]{this.minZ, this.maxZ});
}

throw new IllegalArgumentException();
}

@Override
protected boolean contains(double x, double y, double z) {
return (x >= this.x1) && (x < this.x2) && (y >= this.y1) && (y < this.y2) && (z >= this.z1) && (z < this.z2);
return (x >= this.minX) && (x < this.maxX) && (y >= this.minY) && (y < this.maxY) && (z >= this.minZ) && (z < this.maxZ);
}

@Override
public boolean isEmpty() {
return ((this.x1 + EPSILON) > this.x2) || ((this.y1 + EPSILON) > this.y2) || ((this.z1 + EPSILON) > this.z2);
return ((this.minX + EPSILON) > this.maxX) || ((this.minY + EPSILON) > this.maxY) || ((this.minZ + EPSILON) > this.maxZ);
}

@Override
protected int getCoordIndex(Direction.Axis axis, double coord) {
if (coord < this.getMinimum(axis)) {
if (coord < this.getMin(axis)) {
return -1;
}

if (coord >= this.getMaximum(axis)) {
if (coord >= this.getMax(axis)) {
return 1;
}

Expand All @@ -191,8 +191,8 @@ private static boolean lessThan(double a, double b) {

@Override
public boolean intersects(Box box, double x, double y, double z) {
return (box.x1 < (this.x2 + x)) && (box.x2 > (this.x1 + x)) &&
(box.y1 < (this.y2 + y)) && (box.y2 > (this.y1 + y)) &&
(box.z1 < (this.z2 + z)) && (box.z2 > (this.z1 + z));
return (box.minX < (this.maxX + x)) && (box.maxX > (this.minX + x)) &&
(box.minY < (this.maxY + y)) && (box.maxY > (this.minY + y)) &&
(box.minZ < (this.maxZ + z)) && (box.maxZ > (this.minZ + z));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.util.Arrays;
import java.util.function.Function;
import java.util.function.Predicate;

import static it.unimi.dsi.fastutil.Hash.FAST_LOAD_FACTOR;

Expand Down Expand Up @@ -94,8 +95,14 @@ private void resize(int neededCapacity) {
}

@Override
public boolean accepts(T obj) {
return this.table.containsKey(obj);
public boolean accepts(Predicate<T> predicate) {
for (int i = 0; i < this.size; ++i) {
if (predicate.test(this.entries[i])) {
return true;
}
}

return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ public static void init(Set<BlockState> types) {
}

public static boolean shouldScan(ChunkSection section) {
for (BlockState state : TYPES) {
if (section.method_19523(state)) {
return true;
}
}

return false;
return section.method_19523(TYPES::contains);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet;
import net.minecraft.entity.ai.goal.Goal;
import net.minecraft.entity.ai.goal.GoalSelector;
import net.minecraft.entity.ai.goal.WeightedGoal;
import net.minecraft.entity.ai.goal.PrioritizedGoal;
import net.minecraft.util.profiler.Profiler;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -26,15 +26,15 @@ public abstract class MixinGoalSelector {
@Mutable
@Shadow
@Final
private Set<WeightedGoal> goals;
private Set<PrioritizedGoal> goals;

@Shadow
@Final
private EnumSet<Goal.Control> disabledControls;

@Shadow
@Final
private Map<Goal.Control, WeightedGoal> goalsByControl;
private Map<Goal.Control, PrioritizedGoal> goalsByControl;

/**
* Replace the goal set with an optimized collection type which performs better for iteration.
Expand Down Expand Up @@ -79,7 +79,7 @@ private void updateGoalStates() {
* Attempts to stop all goals which are running and either shouldn't continue or no longer have available controls.
*/
private void stopGoals() {
for (WeightedGoal goal : this.goals) {
for (PrioritizedGoal goal : this.goals) {
// Filter out goals which are not running
if (!goal.isRunning()) {
continue;
Expand All @@ -97,7 +97,7 @@ private void stopGoals() {
*/
private void cleanupControls() {
for (Goal.Control control : CONTROLS) {
WeightedGoal goal = this.goalsByControl.get(control);
PrioritizedGoal goal = this.goalsByControl.get(control);

// If the control has been acquired by a goal, check if the goal should still be running
// If the goal should not be running anymore, release the control held by it
Expand All @@ -111,7 +111,7 @@ private void cleanupControls() {
* Attempts to start all goals which are not-already running, can be started, and have their controls available.
*/
private void startGoals() {
for (WeightedGoal goal : this.goals) {
for (PrioritizedGoal goal : this.goals) {
// Filter out goals which are already running or can't be started
if (goal.isRunning() || !goal.canStart()) {
continue;
Expand All @@ -124,7 +124,7 @@ private void startGoals() {

// Hand over controls to this goal and stop any goals which depended on those controls
for (Goal.Control control : goal.getControls()) {
WeightedGoal otherGoal = this.getGoalOccupyingControl(control);
PrioritizedGoal otherGoal = this.getGoalOccupyingControl(control);

if (otherGoal != null) {
otherGoal.stop();
Expand All @@ -144,7 +144,7 @@ private void tickGoals() {
this.profiler.get().push("goalTick");

// Tick all currently running goals
for (WeightedGoal goal : this.goals) {
for (PrioritizedGoal goal : this.goals) {
if (goal.isRunning()) {
goal.tick();
}
Expand All @@ -156,7 +156,7 @@ private void tickGoals() {
/**
* Returns true if any controls of the specified goal are disabled.
*/
private boolean areControlsDisabled(WeightedGoal goal) {
private boolean areControlsDisabled(PrioritizedGoal goal) {
for (Goal.Control control : goal.getControls()) {
if (this.isControlDisabled(control)) {
return true;
Expand All @@ -170,13 +170,13 @@ private boolean areControlsDisabled(WeightedGoal goal) {
* Returns true if all controls for the specified goal are either available (not acquired by another goal) or replaceable
* (acquired by another goal, but eligible for replacement) and not disabled for the entity.
*/
private boolean areGoalControlsAvailable(WeightedGoal goal) {
private boolean areGoalControlsAvailable(PrioritizedGoal goal) {
for (Goal.Control control : goal.getControls()) {
if (this.isControlDisabled(control)) {
return false;
}

WeightedGoal occupied = this.getGoalOccupyingControl(control);
PrioritizedGoal occupied = this.getGoalOccupyingControl(control);

if (occupied != null && !occupied.canBeReplacedBy(goal)) {
return false;
Expand All @@ -196,14 +196,14 @@ private boolean isControlDisabled(Goal.Control control) {
/**
* Returns the goal which is currently holding the specified control, or null if no goal is.
*/
private WeightedGoal getGoalOccupyingControl(Goal.Control control) {
private PrioritizedGoal getGoalOccupyingControl(Goal.Control control) {
return this.goalsByControl.get(control);
}

/**
* Changes the goal which is currently holding onto a control.
*/
private void setGoalOccupyingControl(Goal.Control control, WeightedGoal goal) {
private void setGoalOccupyingControl(Goal.Control control, PrioritizedGoal goal) {
this.goalsByControl.put(control, goal);
}

Expand Down
Loading

0 comments on commit 0ee7055

Please sign in to comment.