Skip to content

Commit

Permalink
Update to Minecraft Snapshot 20w18a
Browse files Browse the repository at this point in the history
  • Loading branch information
jellysquid3 committed May 5, 2020
1 parent d9376eb commit 05aec34
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 86 deletions.
14 changes: 5 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=20w15a
yarn_mappings=20w15a+build.4
minecraft_version=20w18a
yarn_mappings=20w18a+build.14
loader_version=0.8.2+build.194

# Mod Properties
fabric_asm_version=v2.0
mod_version = 0.5.0
maven_group = me.jellysquid.mods
archives_base_name = lithium-fabric

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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.jellysquid.mods.lithium.common.entity.tracker.nearby;

import me.jellysquid.mods.lithium.common.util.LithiumMath;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.TargetPredicate;
import net.minecraft.util.math.Box;
Expand All @@ -25,7 +26,7 @@ public NearbyEntityTracker(Class<T> clazz, LivingEntity self, float range) {
this.clazz = clazz;
this.self = self;
this.rangeSq = range * range;
this.rangeC = MathHelper.roundUp(MathHelper.ceil(range), 16) >> 4;
this.rangeC = LithiumMath.roundUp(MathHelper.ceil(range), 16) >> 4;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package me.jellysquid.mods.lithium.common.util;

public class LithiumMath {
public static int roundUp(int num, int interval) {
return ((num + (interval - 1)) / interval) * interval;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import me.jellysquid.mods.lithium.common.entity.tracker.EntityTrackerEngine;
import me.jellysquid.mods.lithium.common.entity.tracker.EntityTrackerEngineProvider;
import net.minecraft.class_5269;
import net.minecraft.util.profiler.Profiler;
import net.minecraft.world.World;
import net.minecraft.world.chunk.ChunkManager;
import net.minecraft.world.dimension.Dimension;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.level.LevelProperties;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -27,7 +27,7 @@ public class MixinWorld implements EntityTrackerEngineProvider {
* Initialize the {@link EntityTrackerEngine} which all entities of the world will interact with.
*/
@Inject(method = "<init>", at = @At("RETURN"))
private void init(LevelProperties levelProperties, DimensionType dimensionType, BiFunction<World, Dimension, ChunkManager> chunkManagerProvider, Supplier<Profiler> profiler, boolean isClient, CallbackInfo ci) {
private void init(class_5269 levelProperties, DimensionType dimensionType, BiFunction<World, Dimension, ChunkManager> chunkManagerProvider, Supplier<Profiler> profiler, boolean isClient, CallbackInfo ci) {
this.tracker = new EntityTrackerEngine();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void run(ServerWorld world, LivingEntity self, long time) {

if (this.test(entity)) {
brain.remember(MemoryModuleType.INTERACTION_TARGET, entity);
brain.remember(MemoryModuleType.LOOK_TARGET, new EntityLookTarget(entity));
brain.remember(MemoryModuleType.LOOK_TARGET, new EntityLookTarget(entity, true));

break;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Biome getBiome(long seed, int x, int y, int z, BiomeAccess.Storage storag

// This code would normally allocate an array to store each iteration's results, then scan back over it
// to determine the closest one. We can avoid the unnecessary step and simply keep track of the nearest one.
double min = Double.POSITIVE_INFINITY;
double minDist = Double.POSITIVE_INFINITY;

for (int i = 0; i < 8; i++) {
// Block sample positions
Expand Down Expand Up @@ -72,10 +72,10 @@ public Biome getBiome(long seed, int x, int y, int z, BiomeAccess.Storage storag
sZ = z3 - 1.0D;
}

double result = calcChance(seed, bX, bY, bZ, sX, sY, sZ);
double dist = calcSquaredDistance(seed, bX, bY, bZ, sX, sY, sZ);

if (min > result) {
min = result;
if (minDist > dist) {
minDist = dist;

retX = bX;
retY = bY;
Expand All @@ -96,7 +96,7 @@ private static double distribute(long seed) {
}

@Shadow
private static double calcChance(long seed, int x, int y, int z, double xFraction, double yFraction, double zFraction) {
private static double calcSquaredDistance(long seed, int x, int y, int z, double xFraction, double yFraction, double zFraction) {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import java.util.Arrays;

/**
* Extends {@link PackedIntegerArray} with a special compaction method defined in {@link CompactingPackedIntegerArray}.
*/
Expand All @@ -30,6 +28,10 @@ public class MixinPackedIntegerArray implements CompactingPackedIntegerArray {
@Final
private long maxValue;

@Shadow
@Final
private int field_24079;

@Override
public <T> void compact(Palette<T> srcPalette, Palette<T> dstPalette, short[] out) {
if (this.size >= Short.MAX_VALUE) {
Expand All @@ -42,57 +44,29 @@ public <T> void compact(Palette<T> srcPalette, Palette<T> dstPalette, short[] ou

short[] mappings = new short[(int) (this.maxValue + 1)];

long[] storage = this.storage;
int size = this.size;
int elementBits = this.elementBits;

int arrayLen = storage.length;
int prevWordIdx = 0;

long word = storage[0];
long nextWord = (arrayLen > 1) ? storage[1] : 0L;

int bits = 0;
int idx = 0;

while (idx < size) {
int wordIdx = bits >> 6;
int nextWordIdx = ((bits + elementBits) - 1) >> 6;

int bitIdx = bits ^ (wordIdx << 6);
for (long word : this.storage) {
long bits = word;

if (wordIdx != prevWordIdx) {
word = nextWord;
for (int elementIdx = 0; elementIdx < this.field_24079; ++elementIdx) {
int value = (int) (bits & this.maxValue);
int remappedId = mappings[value];

if ((wordIdx + 1) < arrayLen) {
nextWord = storage[wordIdx + 1];
} else {
nextWord = 0L;
if (remappedId == 0) {
remappedId = dstPalette.getIndex(srcPalette.getByIndex(value)) + 1;
mappings[value] = (short) remappedId;
}

prevWordIdx = wordIdx;
}

int value;

if (wordIdx == nextWordIdx) {
value = (int) ((word >>> bitIdx) & this.maxValue);
} else {
value = (int) (((word >>> bitIdx) | (nextWord << (64 - bitIdx))) & this.maxValue);
}
out[idx] = (short) (remappedId - 1);
bits >>= this.elementBits;

int remappedId = mappings[value];
++idx;

if (remappedId == 0) {
remappedId = dstPalette.getIndex(srcPalette.getByIndex(value)) + 1;

mappings[value] = (short) remappedId;
if (idx >= this.size) {
return;
}
}

out[idx] = (short) (remappedId - 1);

bits += elementBits;
idx++;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.jellysquid.mods.lithium.mixin.entity.fluid_checks;

import it.unimi.dsi.fastutil.objects.Object2DoubleMap;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
Expand Down Expand Up @@ -50,7 +51,7 @@ public abstract class MixinEntity {
public abstract void setVelocity(Vec3d velocity);

@Shadow
protected double waterHeight;
protected Object2DoubleMap<Tag<Fluid>> fluidHeight;

private static final ObjectArrayList<Tag<Fluid>> DEFAULT_FLUID_TAGS = new ObjectArrayList<>();

Expand Down Expand Up @@ -107,7 +108,7 @@ private void preUpdateMovementInFluid(Tag<Fluid> tag, double d, CallbackInfoRetu
// [VanillaCopy]
// The value of the waterHeight field is *always* that of the last movement check through fluid. This is a
// bug from vanilla and must be maintained.
this.waterHeight = info.height;
this.fluidHeight.put(tag, info.height);

// Regardless of the entity actually being pushed by the fluid, we must indicate that it did collide with it
cir.setReturnValue(true);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"accessWidener": "lithium.accesswidener",
"depends": {
"fabricloader": ">=0.8.0",
"minecraft": "1.16-alpha.20.15.a"
"minecraft": "1.16-alpha.20.18.a"
}
}
1 change: 0 additions & 1 deletion src/main/resources/lithium.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"alloc.enum_values.MixinLivingEntity",
"alloc.enum_values.MixinPistonBlock",
"alloc.enum_values.MixinPistonHandler",
"alloc.enum_values.MixinServerChunkManager",
"biome.MixinVoronoiBiomeAccessType",
"block.flatten_states.MixinAbstractBlockState",
"block.flatten_states.MixinFluidStateImpl",
Expand Down

0 comments on commit 05aec34

Please sign in to comment.