This commit is contained in:
gnembon committed 2020-09-07 15:16:15 -03:00
1 parent a9572236dd
commit 7daac70f93
7 files changed
+27 -25

No files matched your search

+2 -2
View File
@@ -5,8 +5,8 @@ org.gradle.jvmargs=-Xmx1G
# check these on https://fabricmc.net/use # check these on https://fabricmc.net/use
# or better: https://modmuss50.me/fabric.html # or better: https://modmuss50.me/fabric.html
minecraft_version=1.16.2 minecraft_version=1.16.2
yarn_mappings=1.16.2+build.12 yarn_mappings=1.16.2+build.47
loader_version=0.9.1+build.205 loader_version=0.9.3+build.207
# Mod Properties # Mod Properties
mod_version = 1.4.9+v200815 mod_version = 1.4.9+v200815
+4 -3
View File
@@ -6,7 +6,7 @@ import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.util.hit.HitResult; import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.Box; import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.RayTraceContext; import net.minecraft.world.RaycastContext;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.Optional; import java.util.Optional;
@@ -31,7 +31,8 @@ public class Tracer
Vec3d pos = source.getCameraPosVec(partialTicks); Vec3d pos = source.getCameraPosVec(partialTicks);
Vec3d rotation = source.getRotationVec(partialTicks); Vec3d rotation = source.getRotationVec(partialTicks);
Vec3d reachEnd = pos.add(rotation.x * reach, rotation.y * reach, rotation.z * reach); Vec3d reachEnd = pos.add(rotation.x * reach, rotation.y * reach, rotation.z * reach);
return source.world.rayTrace(new RayTraceContext(pos, reachEnd, RayTraceContext.ShapeType.OUTLINE, fluids ? RayTraceContext.FluidHandling.ANY : RayTraceContext.FluidHandling.NONE, source)); return source.world.raycast(new RaycastContext(pos, reachEnd, RaycastContext.ShapeType.OUTLINE, fluids ?
RaycastContext.FluidHandling.ANY : RaycastContext.FluidHandling.NONE, source));
} }
public static EntityHitResult rayTraceEntities(Entity source, float partialTicks, double reach, double maxSqDist) public static EntityHitResult rayTraceEntities(Entity source, float partialTicks, double reach, double maxSqDist)
@@ -51,7 +52,7 @@ public class Tracer
for (Entity current : world.getOtherEntities(source, box, predicate)) for (Entity current : world.getOtherEntities(source, box, predicate))
{ {
Box currentBox = current.getBoundingBox().expand(current.getTargetingMargin()); Box currentBox = current.getBoundingBox().expand(current.getTargetingMargin());
Optional<Vec3d> currentHit = currentBox.rayTrace(start, end); Optional<Vec3d> currentHit = currentBox.raycast(start, end);
if (currentBox.contains(start)) if (currentBox.contains(start))
{ {
if (targetDistance >= 0) if (targetDistance >= 0)
@@ -48,7 +48,7 @@ public class SpawnHelperMixin
@Redirect(method = "canSpawn(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/entity/SpawnGroup;Lnet/minecraft/world/gen/StructureAccessor;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Lnet/minecraft/world/biome/SpawnSettings$SpawnEntry;Lnet/minecraft/util/math/BlockPos$Mutable;D)Z", at = @At( @Redirect(method = "canSpawn(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/entity/SpawnGroup;Lnet/minecraft/world/gen/StructureAccessor;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Lnet/minecraft/world/biome/SpawnSettings$SpawnEntry;Lnet/minecraft/util/math/BlockPos$Mutable;D)Z", at = @At(
value = "INVOKE", value = "INVOKE",
target = "Lnet/minecraft/server/world/ServerWorld;doesNotCollide(Lnet/minecraft/util/math/Box;)Z" target = "Lnet/minecraft/server/world/ServerWorld;isSpaceEmpty(Lnet/minecraft/util/math/Box;)Z"
)) ))
private static boolean doesNotCollide(ServerWorld world, Box bb) private static boolean doesNotCollide(ServerWorld world, Box bb)
{ {
@@ -58,7 +58,7 @@ public class SpawnHelperMixin
// in case something more complex happens - we default to full block collision check // in case something more complex happens - we default to full block collision check
if (!CarpetSettings.lagFreeSpawning) if (!CarpetSettings.lagFreeSpawning)
{ {
return world.doesNotCollide(bb); return world.isSpaceEmpty(bb);
} }
int minX = MathHelper.floor(bb.minX); int minX = MathHelper.floor(bb.minX);
int minY = MathHelper.floor(bb.minY); int minY = MathHelper.floor(bb.minY);
@@ -79,7 +79,7 @@ public class SpawnHelperMixin
} }
else else
{ {
return world.doesNotCollide(bb); return world.isSpaceEmpty(bb);
} }
} }
} }
@@ -102,7 +102,7 @@ public class SpawnHelperMixin
} }
else else
{ {
return world.doesNotCollide(bb); return world.isSpaceEmpty(bb);
} }
} }
} }
@@ -122,7 +122,7 @@ public class SpawnHelperMixin
((block instanceof FenceGateBlock) && !state.get(FenceGateBlock.OPEN)) ((block instanceof FenceGateBlock) && !state.get(FenceGateBlock.OPEN))
) )
{ {
if (x == minX || x == maxX || z == minZ || z == maxZ) return world.doesNotCollide(bb); if (x == minX || x == maxX || z == minZ || z == maxZ) return world.isSpaceEmpty(bb);
return false; return false;
} }
} }
@@ -117,7 +117,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
@Unique @Unique
private void addTicket(final ChunkPos pos, final ChunkStatus status) private void addTicket(final ChunkPos pos, final ChunkStatus status)
{ // UNKNOWN { // UNKNOWN
this.ticketManager.addTicketWithLevel(ChunkTicketType.field_14032, pos, 33 + ChunkStatus.getDistanceFromFull(status), pos); this.ticketManager.addTicketWithLevel(ChunkTicketType.UNKNOWN, pos, 33 + ChunkStatus.getDistanceFromFull(status), pos);
} }
@Unique @Unique
@@ -1290,7 +1290,8 @@ public class CarpetExpression
{ {
ChunkPos chpos = new ChunkPos(chx, chz); ChunkPos chpos = new ChunkPos(chx, chz);
// getting a chunk will convert it to full, allowing to modify references // getting a chunk will convert it to full, allowing to modify references
Map<StructureFeature<?>, LongSet> references = world.getChunk(chpos.getCenterBlockPos()).getStructureReferences(); Map<StructureFeature<?>, LongSet> references =
world.getChunk(chpos.getStartPos()).getStructureReferences();
if (references.containsKey(structure) && references.get(structure) != null) if (references.containsKey(structure) && references.get(structure) != null)
references.get(structure).remove(structureChunkPos.toLong()); references.get(structure).remove(structureChunkPos.toLong());
} }
@@ -1390,7 +1391,7 @@ public class CarpetExpression
{ {
if (world.getChunk(chpos.x, chpos.z, ChunkStatus.FULL, false) != null) if (world.getChunk(chpos.x, chpos.z, ChunkStatus.FULL, false) != null)
{ {
forceChunkUpdate(chpos.getCenterBlockPos(), world); forceChunkUpdate(chpos.getStartPos(), world);
} }
} }
result[0] = MapValue.wrap(report.entrySet().stream().collect(Collectors.toMap( result[0] = MapValue.wrap(report.entrySet().stream().collect(Collectors.toMap(
@@ -1440,21 +1441,21 @@ public class CarpetExpression
if (radius < 1 || radius > 32) throw new InternalExpressionException("Ticket radius should be between 1 and 32 chunks"); if (radius < 1 || radius > 32) throw new InternalExpressionException("Ticket radius should be between 1 and 32 chunks");
// due to types we will wing it: // due to types we will wing it:
ChunkPos target = new ChunkPos(pos); ChunkPos target = new ChunkPos(pos);
if (ticket == ChunkTicketType.field_19280) // portal if (ticket == ChunkTicketType.PORTAL) // portal
cc.s.getWorld().getChunkManager().addTicket(ChunkTicketType.field_19280, target, radius, pos); cc.s.getWorld().getChunkManager().addTicket(ChunkTicketType.PORTAL, target, radius, pos);
else if (ticket == ChunkTicketType.field_19347) // post teleport else if (ticket == ChunkTicketType.POST_TELEPORT) // post teleport
cc.s.getWorld().getChunkManager().addTicket(ChunkTicketType.field_19347, target, radius, 1); cc.s.getWorld().getChunkManager().addTicket(ChunkTicketType.POST_TELEPORT, target, radius, 1);
else else
cc.s.getWorld().getChunkManager().addTicket(ChunkTicketType.field_14032, target, radius, target); cc.s.getWorld().getChunkManager().addTicket(ChunkTicketType.UNKNOWN, target, radius, target);
Value ret = new NumericValue(ticket.getExpiryTicks()); Value ret = new NumericValue(ticket.getExpiryTicks());
return (_c, _t) -> ret; return (_c, _t) -> ret;
}); });
} }
private Map<String, ChunkTicketType<?>> ticketTypes = new HashMap<String, ChunkTicketType<?>>(){{ private Map<String, ChunkTicketType<?>> ticketTypes = new HashMap<String, ChunkTicketType<?>>(){{
put("portal", ChunkTicketType.field_19280); put("portal", ChunkTicketType.PORTAL);
put("teleport", ChunkTicketType.field_19347); put("teleport", ChunkTicketType.POST_TELEPORT);
put("unknown", ChunkTicketType.field_14032); // unknown put("unknown", ChunkTicketType.UNKNOWN); // unknown
}}; }};
private static String getScoreboardKeyFromValue(Value keyValue) private static String getScoreboardKeyFromValue(Value keyValue)
@@ -3585,7 +3586,7 @@ public class CarpetExpression
else else
{ {
String catString = lv.get(0).evalValue(c).getString(); String catString = lv.get(0).evalValue(c).getString();
SpawnGroup cat = SpawnGroup.method_28307(catString.toLowerCase(Locale.ROOT)); SpawnGroup cat = SpawnGroup.byName(catString.toLowerCase(Locale.ROOT));
if (cat == null) throw new InternalExpressionException("Unreconized mob category: "+catString); if (cat == null) throw new InternalExpressionException("Unreconized mob category: "+catString);
retVal = ListValue.of( retVal = ListValue.of(
new NumericValue(mobcounts.getInt(cat)), new NumericValue(mobcounts.getInt(cat)),
@@ -183,7 +183,7 @@ public class PerimeterDiagnostics
el.refreshPositionAndAngles((float)pos.getX() + 0.5F, (float)pos.getY(), (float)pos.getZ()+0.5F, 0.0F, 0.0F); el.refreshPositionAndAngles((float)pos.getX() + 0.5F, (float)pos.getY(), (float)pos.getZ()+0.5F, 0.0F, 0.0F);
return el.canSpawn(worldServer) && el.canSpawn(worldServer, SpawnReason.NATURAL) && return el.canSpawn(worldServer) && el.canSpawn(worldServer, SpawnReason.NATURAL) &&
SpawnRestriction.canSpawn(el.getType(),(ServerWorld)el.getEntityWorld(), SpawnReason.NATURAL, el.getBlockPos(), el.getEntityWorld().random) && SpawnRestriction.canSpawn(el.getType(),(ServerWorld)el.getEntityWorld(), SpawnReason.NATURAL, el.getBlockPos(), el.getEntityWorld().random) &&
worldServer.doesNotCollide(el); // check collision rules once they stop fiddling with them after 1.14.1 worldServer.isSpaceEmpty(el); // check collision rules once they stop fiddling with them after 1.14.1
} }
return false; return false;
} }
@@ -467,7 +467,7 @@ public class SpawnReporter
float f = (float)x + 0.5F; float f = (float)x + 0.5F;
float f1 = (float)z + 0.5F; float f1 = (float)z + 0.5F;
mob.refreshPositionAndAngles((double)f, (double)y, (double)f1, worldIn.random.nextFloat() * 360.0F, 0.0F); mob.refreshPositionAndAngles((double)f, (double)y, (double)f1, worldIn.random.nextFloat() * 360.0F, 0.0F);
fits1 = worldIn.doesNotCollide(mob); fits1 = worldIn.isSpaceEmpty(mob);
EntityType etype = mob.getType(); EntityType etype = mob.getType();
for (int i = 0; i < 20; ++i) for (int i = 0; i < 20; ++i)
@@ -483,7 +483,7 @@ public class SpawnReporter
} }
mob.initialize(worldIn, worldIn.getLocalDifficulty(mob.getBlockPos()), SpawnReason.NATURAL, null, null); mob.initialize(worldIn, worldIn.getLocalDifficulty(mob.getBlockPos()), SpawnReason.NATURAL, null, null);
// the code invokes onInitialSpawn after getCanSpawHere // the code invokes onInitialSpawn after getCanSpawHere
fits = fits1 && worldIn.doesNotCollide(mob); fits = fits1 && worldIn.isSpaceEmpty(mob);
if (fits) if (fits)
{ {
fits_true = true; fits_true = true;