Migrate the Carpet codebase to Mojang Mappings

This commit is contained in:
altrisi committed 2022-01-24 20:33:16 +01:00
1 parent a1a2488bc3
commit 06af9ce8b1
346 files changed
+8353 -8492

No files matched your search

@@ -2,13 +2,6 @@ package carpet.mixins;
import carpet.CarpetSettings;
import carpet.fakes.WorldInterface;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.world.GameRules;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -16,63 +9,70 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntitySelector;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
@Mixin(LivingEntity.class)
public abstract class LivingEntity_maxCollisionsMixin extends Entity
{
public LivingEntity_maxCollisionsMixin(EntityType<?> entityType_1, World world_1)
public LivingEntity_maxCollisionsMixin(EntityType<?> entityType_1, Level world_1)
{
super(entityType_1, world_1);
}
@Shadow protected abstract void pushAway(Entity entity_1);
@Shadow protected abstract void doPush(Entity entity_1);
@Inject(method = "tickCramming", cancellable = true, at = @At("HEAD"))
@Inject(method = "pushEntities", cancellable = true, at = @At("HEAD"))
private void tickPushingReplacement(CallbackInfo ci) {
List<Entity> entities;
int maxEntityCramming =-1;
if (CarpetSettings.maxEntityCollisions > 0)
{
maxEntityCramming = this.world.getGameRules().getInt(GameRules.MAX_ENTITY_CRAMMING);
entities = ((WorldInterface) this.world).getOtherEntitiesLimited(
maxEntityCramming = this.level.getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING);
entities = ((WorldInterface) this.level).getOtherEntitiesLimited(
this,
this.getBoundingBox(),
EntityPredicates.canBePushedBy(this),
EntitySelector.pushableBy(this),
Math.max(CarpetSettings.maxEntityCollisions, maxEntityCramming));
}
else
{
entities = this.world.getOtherEntities(this, this.getBoundingBox(), EntityPredicates.canBePushedBy(this));
entities = this.level.getEntities(this, this.getBoundingBox(), EntitySelector.pushableBy(this));
}
if (!entities.isEmpty()) {
if (maxEntityCramming < 0) maxEntityCramming = this.world.getGameRules().getInt(GameRules.MAX_ENTITY_CRAMMING);
if (maxEntityCramming < 0) maxEntityCramming = this.level.getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING);
if (maxEntityCramming > 0 && entities.size() > maxEntityCramming - 1 && this.random.nextInt(4) == 0) {
int candidates = 0;
for (Entity entity : entities) {
if (!entity.hasVehicle()) {
if (!entity.isPassenger()) {
++candidates;
}
}
if (candidates > maxEntityCramming - 1) {
this.damage(DamageSource.CRAMMING, 6.0F);
this.hurt(DamageSource.CRAMMING, 6.0F);
}
}
if (CarpetSettings.maxEntityCollisions > 0 && entities.size() > CarpetSettings.maxEntityCollisions)
{
for (Entity entity : entities.subList(0, CarpetSettings.maxEntityCollisions))
{
this.pushAway(entity);
this.doPush(entity);
}
}
else
{
for (Entity entity : entities)
{
this.pushAway(entity);
this.doPush(entity);
}
}
}