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

+4 -3
View File
@@ -6,7 +6,7 @@ import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.RayTraceContext;
import net.minecraft.world.RaycastContext;
import net.minecraft.world.World;
import java.util.Optional;
@@ -31,7 +31,8 @@ public class Tracer
Vec3d pos = source.getCameraPosVec(partialTicks);
Vec3d rotation = source.getRotationVec(partialTicks);
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)
@@ -51,7 +52,7 @@ public class Tracer
for (Entity current : world.getOtherEntities(source, box, predicate))
{
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 (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(
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)
{
@@ -58,7 +58,7 @@ public class SpawnHelperMixin
// in case something more complex happens - we default to full block collision check
if (!CarpetSettings.lagFreeSpawning)
{
return world.doesNotCollide(bb);
return world.isSpaceEmpty(bb);
}
int minX = MathHelper.floor(bb.minX);
int minY = MathHelper.floor(bb.minY);
@@ -79,7 +79,7 @@ public class SpawnHelperMixin
}
else
{
return world.doesNotCollide(bb);
return world.isSpaceEmpty(bb);
}
}
}
@@ -102,7 +102,7 @@ public class SpawnHelperMixin
}
else
{
return world.doesNotCollide(bb);
return world.isSpaceEmpty(bb);
}
}
}
@@ -122,7 +122,7 @@ public class SpawnHelperMixin
((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;
}
}
@@ -117,7 +117,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
@Unique
private void addTicket(final ChunkPos pos, final ChunkStatus status)
{ // 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
@@ -1290,7 +1290,8 @@ public class CarpetExpression
{
ChunkPos chpos = new ChunkPos(chx, chz);
// 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)
references.get(structure).remove(structureChunkPos.toLong());
}
@@ -1390,7 +1391,7 @@ public class CarpetExpression
{
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(
@@ -1440,21 +1441,21 @@ public class CarpetExpression
if (radius < 1 || radius > 32) throw new InternalExpressionException("Ticket radius should be between 1 and 32 chunks");
// due to types we will wing it:
ChunkPos target = new ChunkPos(pos);
if (ticket == ChunkTicketType.field_19280) // portal
cc.s.getWorld().getChunkManager().addTicket(ChunkTicketType.field_19280, target, radius, pos);
else if (ticket == ChunkTicketType.field_19347) // post teleport
cc.s.getWorld().getChunkManager().addTicket(ChunkTicketType.field_19347, target, radius, 1);
if (ticket == ChunkTicketType.PORTAL) // portal
cc.s.getWorld().getChunkManager().addTicket(ChunkTicketType.PORTAL, target, radius, pos);
else if (ticket == ChunkTicketType.POST_TELEPORT) // post teleport
cc.s.getWorld().getChunkManager().addTicket(ChunkTicketType.POST_TELEPORT, target, radius, 1);
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());
return (_c, _t) -> ret;
});
}
private Map<String, ChunkTicketType<?>> ticketTypes = new HashMap<String, ChunkTicketType<?>>(){{
put("portal", ChunkTicketType.field_19280);
put("teleport", ChunkTicketType.field_19347);
put("unknown", ChunkTicketType.field_14032); // unknown
put("portal", ChunkTicketType.PORTAL);
put("teleport", ChunkTicketType.POST_TELEPORT);
put("unknown", ChunkTicketType.UNKNOWN); // unknown
}};
private static String getScoreboardKeyFromValue(Value keyValue)
@@ -3585,7 +3586,7 @@ public class CarpetExpression
else
{
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);
retVal = ListValue.of(
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);
return el.canSpawn(worldServer) && el.canSpawn(worldServer, SpawnReason.NATURAL) &&
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;
}
@@ -467,7 +467,7 @@ public class SpawnReporter
float f = (float)x + 0.5F;
float f1 = (float)z + 0.5F;
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();
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);
// the code invokes onInitialSpawn after getCanSpawHere
fits = fits1 && worldIn.doesNotCollide(mob);
fits = fits1 && worldIn.isSpaceEmpty(mob);
if (fits)
{
fits_true = true;