Remove a few no longer needed mixins (#1243)

This commit is contained in:
altrisi authored and GitHub committed 2022-01-08 23:18:13 +01:00
1 parent 763abe68c9
commit 212b6a792e
12 files changed
+10 -152

No files matched your search

@@ -1,12 +0,0 @@
package carpet.fakes;
import java.util.Optional;
public interface BiomeEffectsInterface
{
int getCMFogColor();
Optional<Integer> getCMFoliageColor();
int getCMSkyColor();
int getCMWaterColor();
int getCMWaterFogColor();
}
@@ -1,12 +0,0 @@
package carpet.fakes;
import net.minecraft.entity.ai.brain.Memory;
import net.minecraft.entity.ai.brain.MemoryModuleType;
import java.util.Map;
import java.util.Optional;
public interface BrainInterface
{
Map<MemoryModuleType<?>, Optional<? extends Memory<?>>> getMobMemories();
}
@@ -2,6 +2,5 @@ package carpet.fakes;
public interface ItemEntityInterface public interface ItemEntityInterface
{ {
int getAgeCM();
int getPickupDelayCM(); int getPickupDelayCM();
} }
@@ -1,6 +0,0 @@
package carpet.fakes;
public interface MemoryInterface
{
long getScarpetExpiry();
}
@@ -1,53 +0,0 @@
package carpet.mixins;
import carpet.fakes.BiomeEffectsInterface;
import net.minecraft.world.biome.BiomeEffects;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.Optional;
@Mixin(BiomeEffects.class)
public class BiomeEffects_scarpetMixin implements BiomeEffectsInterface
{
@Shadow @Final private int fogColor;
@Shadow @Final private Optional<Integer> foliageColor;
@Shadow @Final private int skyColor;
@Shadow @Final private int waterColor;
@Shadow @Final private int waterFogColor;
@Override
public int getCMFogColor()
{
return fogColor;
}
@Override
public Optional<Integer> getCMFoliageColor()
{
return foliageColor;
}
@Override
public int getCMSkyColor()
{
return skyColor;
}
@Override
public int getCMWaterColor()
{
return waterColor;
}
@Override
public int getCMWaterFogColor()
{
return waterFogColor;
}
}
@@ -1,25 +0,0 @@
package carpet.mixins;
import carpet.fakes.BrainInterface;
import net.minecraft.entity.ai.brain.Brain;
import net.minecraft.entity.ai.brain.Memory;
import net.minecraft.entity.ai.brain.MemoryModuleType;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.Map;
import java.util.Optional;
@Mixin(Brain.class)
public class Brain_Mixin implements BrainInterface
{
@Shadow @Final private Map<MemoryModuleType<?>, Optional<? extends Memory<?>>> memories;
@Override
public Map<MemoryModuleType<?>, Optional<? extends Memory<?>>> getMobMemories()
{
return memories;
}
}
@@ -42,11 +42,6 @@ public abstract class ItemEntityMixin extends Entity implements ItemEntityInterf
} }
} }
@Override
public int getAgeCM() {
return this.itemAge;
}
@Override @Override
public int getPickupDelayCM() { public int getPickupDelayCM() {
return this.pickupDelay; return this.pickupDelay;
@@ -105,7 +100,7 @@ public abstract class ItemEntityMixin extends Entity implements ItemEntityInterf
self.setStack(selfStack); self.setStack(selfStack);
this.pickupDelay = Math.max(((ItemEntityInterface)other).getPickupDelayCM(), this.pickupDelay); this.pickupDelay = Math.max(((ItemEntityInterface)other).getPickupDelayCM(), this.pickupDelay);
this.itemAge = Math.min(((ItemEntityInterface)other).getAgeCM(), this.itemAge); this.itemAge = Math.min(other.getItemAge(), this.itemAge);
otherStack.decrement(amount); otherStack.decrement(amount);
if (otherStack.isEmpty()) if (otherStack.isEmpty())
@@ -1,18 +0,0 @@
package carpet.mixins;
import carpet.fakes.MemoryInterface;
import net.minecraft.entity.ai.brain.Memory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(Memory.class)
public class Memory_scarpetMixin implements MemoryInterface
{
@Shadow private long expiry;
@Override
public long getScarpetExpiry()
{
return expiry;
}
}
@@ -1,7 +1,5 @@
package carpet.mixins; package carpet.mixins;
import carpet.fakes.BrainInterface;
import carpet.fakes.MemoryInterface;
import carpet.helpers.ParticleDisplay; import carpet.helpers.ParticleDisplay;
import carpet.utils.Messenger; import carpet.utils.Messenger;
import carpet.utils.MobAI; import carpet.utils.MobAI;
@@ -63,14 +61,14 @@ public abstract class VillagerEntity_aiMixin extends MerchantEntity
if (MobAI.isTracking(this, MobAI.TrackingType.IRON_GOLEM_SPAWNING)) if (MobAI.isTracking(this, MobAI.TrackingType.IRON_GOLEM_SPAWNING))
{ {
long time; long time;
Optional<? extends Memory<?>> last_seen = ((BrainInterface)this.brain).getMobMemories().get(MemoryModuleType.GOLEM_DETECTED_RECENTLY); Optional<? extends Memory<?>> last_seen = this.brain.getMemories().get(MemoryModuleType.GOLEM_DETECTED_RECENTLY);
if (!last_seen.isPresent()) if (!last_seen.isPresent())
{ {
time = 0; time = 0;
} }
else else
{ {
time = ((MemoryInterface)last_seen.get()).getScarpetExpiry(); time = last_seen.get().getExpiry();
} }
boolean recentlySeen = time > 0; boolean recentlySeen = time > 0;
Optional<Long> optional_11 = this.brain.getOptionalMemory(MemoryModuleType.LAST_SLEPT); Optional<Long> optional_11 = this.brain.getOptionalMemory(MemoryModuleType.LAST_SLEPT);
@@ -1,15 +1,12 @@
package carpet.script.utils; package carpet.script.utils;
import carpet.fakes.BiomeEffectsInterface;
import carpet.script.value.BlockValue; import carpet.script.value.BlockValue;
import carpet.script.value.ListValue; import carpet.script.value.ListValue;
import carpet.script.value.NumericValue; import carpet.script.value.NumericValue;
import carpet.script.value.StringValue; import carpet.script.value.StringValue;
import carpet.script.value.Value; import carpet.script.value.Value;
import carpet.script.value.ValueConversions; import carpet.script.value.ValueConversions;
import net.minecraft.client.color.world.FoliageColors;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.ConfiguredFeature;
@@ -26,11 +23,11 @@ public class BiomeInfo
put("under_material", (w, b) -> new BlockValue( b.getGenerationSettings().getSurfaceConfig().getUnderMaterial(), null, null)); put("under_material", (w, b) -> new BlockValue( b.getGenerationSettings().getSurfaceConfig().getUnderMaterial(), null, null));
put("category", (w, b) -> StringValue.of(b.getCategory().getName())); put("category", (w, b) -> StringValue.of(b.getCategory().getName()));
put("temperature", (w, b) -> NumericValue.of(b.getTemperature())); put("temperature", (w, b) -> NumericValue.of(b.getTemperature()));
put("fog_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMFogColor())); put("fog_color", (w, b) -> ValueConversions.ofRGB(b.getEffects().getFogColor()));
put("foliage_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMFoliageColor().orElse(4764952))); // client Biome.getDefaultFoliageColor put("foliage_color", (w, b) -> ValueConversions.ofRGB(b.getEffects().getFoliageColor().orElse(4764952))); // client Biome.getDefaultFoliageColor
put("sky_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMSkyColor())); put("sky_color", (w, b) -> ValueConversions.ofRGB(b.getEffects().getSkyColor()));
put("water_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMWaterColor())); put("water_color", (w, b) -> ValueConversions.ofRGB(b.getEffects().getWaterColor()));
put("water_fog_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMWaterFogColor())); put("water_fog_color", (w, b) -> ValueConversions.ofRGB(b.getEffects().getWaterFogColor()));
put("humidity", (w, b) -> NumericValue.of(b.getDownfall())); put("humidity", (w, b) -> NumericValue.of(b.getDownfall()));
put("precipitation", (w, b) -> StringValue.of(b.getPrecipitation().getName())); put("precipitation", (w, b) -> StringValue.of(b.getPrecipitation().getName()));
put("depth", (w, b) -> NumericValue.of(b.getDepth())); put("depth", (w, b) -> NumericValue.of(b.getDepth()));
@@ -1,10 +1,8 @@
package carpet.script.value; package carpet.script.value;
import carpet.fakes.BrainInterface;
import carpet.fakes.EntityInterface; import carpet.fakes.EntityInterface;
import carpet.fakes.ItemEntityInterface; import carpet.fakes.ItemEntityInterface;
import carpet.fakes.LivingEntityInterface; import carpet.fakes.LivingEntityInterface;
import carpet.fakes.MemoryInterface;
import carpet.fakes.MobEntityInterface; import carpet.fakes.MobEntityInterface;
import carpet.fakes.ServerPlayerEntityInterface; import carpet.fakes.ServerPlayerEntityInterface;
import carpet.fakes.ServerPlayerInteractionManagerInterface; import carpet.fakes.ServerPlayerInteractionManagerInterface;
@@ -633,11 +631,11 @@ public class EntityValue extends Value
if (e instanceof LivingEntity livingEntity) if (e instanceof LivingEntity livingEntity)
{ {
Brain<?> brain = livingEntity.getBrain(); Brain<?> brain = livingEntity.getBrain();
Map<MemoryModuleType<?>, Optional<? extends Memory<?>>> memories = ((BrainInterface)brain).getMobMemories(); Map<MemoryModuleType<?>, Optional<? extends Memory<?>>> memories = brain.getMemories();
Optional<? extends Memory<?>> optmemory = memories.get(moduleType); Optional<? extends Memory<?>> optmemory = memories.get(moduleType);
if (optmemory==null || !optmemory.isPresent()) return Value.NULL; if (optmemory==null || !optmemory.isPresent()) return Value.NULL;
Memory<?> memory = optmemory.get(); Memory<?> memory = optmemory.get();
return ValueConversions.fromTimedMemory(e, ((MemoryInterface)memory).getScarpetExpiry(), memory.getValue()); return ValueConversions.fromTimedMemory(e, memory.getExpiry(), memory.getValue());
} }
return Value.NULL; return Value.NULL;
}); });
-3
View File
@@ -66,8 +66,6 @@
"EntityTrackerEntry_leashFixMixin", "EntityTrackerEntry_leashFixMixin",
"VillagerEntity_aiMixin", "VillagerEntity_aiMixin",
"Brain_Mixin",
"Memory_scarpetMixin",
"PlayerEntity_fakePlayersMixin", "PlayerEntity_fakePlayersMixin",
"ThrownEnderpearlEntity_fakePlayersMixin", "ThrownEnderpearlEntity_fakePlayersMixin",
@@ -189,7 +187,6 @@
"Team_scarpetMixin", "Team_scarpetMixin",
"TradeOutputSlot_scarpetEventMixin", "TradeOutputSlot_scarpetEventMixin",
"BiomeEffects_scarpetMixin",
"ChunkTicketManager_scarpetMixin", "ChunkTicketManager_scarpetMixin",
"PointOfInterest_scarpetMixin", "PointOfInterest_scarpetMixin",
"ServerWorld_scarpetMixin", "ServerWorld_scarpetMixin",