mappings: rename MobEffect to StatusEffect

This commit is contained in:
Bixilon 2021-03-25 18:05:13 +01:00
parent da11f1f0a5
commit 0cb8296b05
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
8 changed files with 34 additions and 30 deletions

View File

@ -33,7 +33,7 @@ class ResourceLocationListParser : CommandParser() {
return connection.mapping.enchantmentRegistry.get(resourceLocation.value) ?: throw EnchantmentNotFoundCommandParseException(stringReader, resourceLocation.key) return connection.mapping.enchantmentRegistry.get(resourceLocation.value) ?: throw EnchantmentNotFoundCommandParseException(stringReader, resourceLocation.key)
} }
if (this == MOB_EFFECT_PARSER) { if (this == MOB_EFFECT_PARSER) {
return connection.mapping.mobEffectRegistry.get(resourceLocation.value) ?: throw MobEffectNotFoundCommandParseException(stringReader, resourceLocation.key) return connection.mapping.statusEffectRegistry.get(resourceLocation.value) ?: throw MobEffectNotFoundCommandParseException(stringReader, resourceLocation.key)
} }
if (this == DIMENSION_EFFECT_PARSER) { if (this == DIMENSION_EFFECT_PARSER) {
return connection.mapping.dimensionRegistry.get(resourceLocation.value) ?: throw DimensionNotFoundCommandParseException(stringReader, resourceLocation.key) return connection.mapping.dimensionRegistry.get(resourceLocation.value) ?: throw DimensionNotFoundCommandParseException(stringReader, resourceLocation.key)

View File

@ -12,11 +12,15 @@
*/ */
package de.bixilon.minosoft.data.entities package de.bixilon.minosoft.data.entities
import de.bixilon.minosoft.data.mappings.MobEffect import de.bixilon.minosoft.data.mappings.StatusEffect
data class StatusEffect(val effect: MobEffect, val amplifier: Int, val duration: Int) { data class StatusEffectInstance(
val statusEffect: StatusEffect,
val amplifier: Int,
val duration: Int,
) {
override fun toString(): String { override fun toString(): String {
return "$effect (amplifier: $amplifier, duration: $duration)" return "$statusEffect (amplifier: $amplifier, duration: $duration)"
} }
} }

View File

@ -17,7 +17,7 @@ import de.bixilon.minosoft.config.StaticConfiguration;
import de.bixilon.minosoft.data.entities.*; import de.bixilon.minosoft.data.entities.*;
import de.bixilon.minosoft.data.inventory.InventorySlots; import de.bixilon.minosoft.data.inventory.InventorySlots;
import de.bixilon.minosoft.data.inventory.Slot; import de.bixilon.minosoft.data.inventory.Slot;
import de.bixilon.minosoft.data.mappings.MobEffect; import de.bixilon.minosoft.data.mappings.StatusEffect;
import de.bixilon.minosoft.data.text.ChatComponent; import de.bixilon.minosoft.data.text.ChatComponent;
import de.bixilon.minosoft.modding.event.events.annotations.Unsafe; import de.bixilon.minosoft.modding.event.events.annotations.Unsafe;
import de.bixilon.minosoft.protocol.network.Connection; import de.bixilon.minosoft.protocol.network.Connection;
@ -37,7 +37,7 @@ public abstract class Entity {
protected final int entityId; protected final int entityId;
protected final UUID uuid; protected final UUID uuid;
protected final HashMap<InventorySlots.EntityInventorySlots, Slot> equipment = new HashMap<>(); protected final HashMap<InventorySlots.EntityInventorySlots, Slot> equipment = new HashMap<>();
protected final HashSet<StatusEffect> effectList = new HashSet<>(); protected final HashSet<StatusEffectInstance> effectList = new HashSet<>();
protected final int versionId; protected final int versionId;
protected Position position; protected Position position;
protected EntityRotation rotation; protected EntityRotation rotation;
@ -86,18 +86,18 @@ public abstract class Entity {
return this.uuid; return this.uuid;
} }
public HashSet<StatusEffect> getEffectList() { public HashSet<StatusEffectInstance> getEffectList() {
return this.effectList; return this.effectList;
} }
public void addEffect(StatusEffect effect) { public void addEffect(StatusEffectInstance effect) {
// effect already applied, maybe the duration or the amplifier changed? // effect already applied, maybe the duration or the amplifier changed?
this.effectList.removeIf(listEffect -> listEffect.getEffect() == effect.getEffect()); this.effectList.removeIf(listEffect -> listEffect.getStatusEffect() == effect.getStatusEffect());
this.effectList.add(effect); this.effectList.add(effect);
} }
public void removeEffect(MobEffect effect) { public void removeEffect(StatusEffect effect) {
this.effectList.removeIf(listEffect -> listEffect.getEffect() == effect); this.effectList.removeIf(listEffect -> listEffect.getStatusEffect() == effect);
} }
public void attachTo(int vehicleId) { public void attachTo(int vehicleId) {

View File

@ -15,7 +15,7 @@ package de.bixilon.minosoft.data.mappings
import com.google.gson.JsonObject import com.google.gson.JsonObject
import de.bixilon.minosoft.data.mappings.versions.VersionMapping import de.bixilon.minosoft.data.mappings.versions.VersionMapping
data class MobEffect( data class StatusEffect(
val resourceLocation: ResourceLocation, val resourceLocation: ResourceLocation,
// ToDo // ToDo
) : RegistryItem { ) : RegistryItem {
@ -23,9 +23,9 @@ data class MobEffect(
return resourceLocation.toString() return resourceLocation.toString()
} }
companion object : ResourceLocationDeserializer<MobEffect> { companion object : ResourceLocationDeserializer<StatusEffect> {
override fun deserialize(mappings: VersionMapping, resourceLocation: ResourceLocation, data: JsonObject): MobEffect { override fun deserialize(mappings: VersionMapping, resourceLocation: ResourceLocation, data: JsonObject): StatusEffect {
return MobEffect(resourceLocation) return StatusEffect(resourceLocation)
} }
} }

View File

@ -40,7 +40,7 @@ class VersionMapping(var version: Version?) {
val itemRegistry: ItemRegistry = ItemRegistry() val itemRegistry: ItemRegistry = ItemRegistry()
val enchantmentRegistry: Registry<Enchantment> = Registry() val enchantmentRegistry: Registry<Enchantment> = Registry()
val particleRegistry: Registry<Particle> = Registry() val particleRegistry: Registry<Particle> = Registry()
val mobEffectRegistry: Registry<MobEffect> = Registry() val statusEffectRegistry: Registry<StatusEffect> = Registry()
val statisticRegistry: Registry<Statistic> = Registry() val statisticRegistry: Registry<Statistic> = Registry()
val biomeRegistry: Registry<Biome> = Registry() val biomeRegistry: Registry<Biome> = Registry()
val dimensionRegistry: Registry<Dimension> = Registry() val dimensionRegistry: Registry<Dimension> = Registry()
@ -72,7 +72,7 @@ class VersionMapping(var version: Version?) {
itemRegistry.setParent(value?.itemRegistry) itemRegistry.setParent(value?.itemRegistry)
enchantmentRegistry.setParent(value?.enchantmentRegistry) enchantmentRegistry.setParent(value?.enchantmentRegistry)
particleRegistry.setParent(value?.particleRegistry) particleRegistry.setParent(value?.particleRegistry)
mobEffectRegistry.setParent(value?.mobEffectRegistry) statusEffectRegistry.setParent(value?.statusEffectRegistry)
blockRegistry.setParent(value?.blockRegistry) blockRegistry.setParent(value?.blockRegistry)
statisticRegistry.setParent(value?.statisticRegistry) statisticRegistry.setParent(value?.statisticRegistry)
biomeRegistry.setParent(value?.biomeRegistry) biomeRegistry.setParent(value?.biomeRegistry)
@ -116,7 +116,7 @@ class VersionMapping(var version: Version?) {
itemRegistry.initialize(pixlyzerData["items"]?.asJsonObject, this, Item.Companion, version!!.isFlattened(), Registry.MetaTypes.BITS_16) itemRegistry.initialize(pixlyzerData["items"]?.asJsonObject, this, Item.Companion, version!!.isFlattened(), Registry.MetaTypes.BITS_16)
enchantmentRegistry.initialize(pixlyzerData["enchantments"]?.asJsonObject, this, Enchantment.Companion) enchantmentRegistry.initialize(pixlyzerData["enchantments"]?.asJsonObject, this, Enchantment.Companion)
particleRegistry.initialize(pixlyzerData["particles"]?.asJsonObject, this, Particle.Companion) particleRegistry.initialize(pixlyzerData["particles"]?.asJsonObject, this, Particle.Companion)
mobEffectRegistry.initialize(pixlyzerData["mob_effect"]?.asJsonObject, this, MobEffect.Companion) statusEffectRegistry.initialize(pixlyzerData["mob_effect"]?.asJsonObject, this, StatusEffect.Companion)
biomeRegistry.initialize(pixlyzerData["biomes"]?.asJsonObject, this, Biome.Companion) biomeRegistry.initialize(pixlyzerData["biomes"]?.asJsonObject, this, Biome.Companion)
dimensionRegistry.initialize(pixlyzerData["dimensions"]?.asJsonObject, this, Dimension.Companion) dimensionRegistry.initialize(pixlyzerData["dimensions"]?.asJsonObject, this, Dimension.Companion)

View File

@ -13,7 +13,7 @@
package de.bixilon.minosoft.protocol.packets.clientbound.play; package de.bixilon.minosoft.protocol.packets.clientbound.play;
import de.bixilon.minosoft.data.entities.StatusEffect; import de.bixilon.minosoft.data.entities.StatusEffectInstance;
import de.bixilon.minosoft.data.entities.entities.Entity; import de.bixilon.minosoft.data.entities.entities.Entity;
import de.bixilon.minosoft.protocol.network.Connection; import de.bixilon.minosoft.protocol.network.Connection;
import de.bixilon.minosoft.protocol.packets.ClientboundPacket; import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
@ -25,7 +25,7 @@ import static de.bixilon.minosoft.protocol.protocol.ProtocolVersions.*;
public class PacketEntityEffect extends ClientboundPacket { public class PacketEntityEffect extends ClientboundPacket {
int entityId; int entityId;
StatusEffect effect; StatusEffectInstance effect;
boolean isAmbient; boolean isAmbient;
boolean hideParticles; boolean hideParticles;
boolean showIcon = true; boolean showIcon = true;
@ -34,10 +34,10 @@ public class PacketEntityEffect extends ClientboundPacket {
public boolean read(InByteBuffer buffer) { public boolean read(InByteBuffer buffer) {
this.entityId = buffer.readEntityId(); this.entityId = buffer.readEntityId();
if (buffer.getVersionId() < V_14W04A) { if (buffer.getVersionId() < V_14W04A) {
this.effect = new StatusEffect(buffer.getConnection().getMapping().getMobEffectRegistry().get(buffer.readByte()), buffer.readByte() + 1, buffer.readShort()); this.effect = new StatusEffectInstance(buffer.getConnection().getMapping().getStatusEffectRegistry().get(buffer.readByte()), buffer.readByte() + 1, buffer.readShort());
return true; return true;
} }
this.effect = new StatusEffect(buffer.getConnection().getMapping().getMobEffectRegistry().get(buffer.readByte()), buffer.readByte() + 1, buffer.readVarInt()); this.effect = new StatusEffectInstance(buffer.getConnection().getMapping().getStatusEffectRegistry().get(buffer.readByte()), buffer.readByte() + 1, buffer.readVarInt());
if (buffer.getVersionId() < V_1_9_4) { // ToDo if (buffer.getVersionId() < V_1_9_4) { // ToDo
if (buffer.getVersionId() >= V_14W06B) { if (buffer.getVersionId() >= V_14W06B) {
this.hideParticles = buffer.readBoolean(); this.hideParticles = buffer.readBoolean();
@ -72,7 +72,7 @@ public class PacketEntityEffect extends ClientboundPacket {
return this.entityId; return this.entityId;
} }
public StatusEffect getEffect() { public StatusEffectInstance getEffect() {
return this.effect; return this.effect;
} }

View File

@ -14,21 +14,21 @@
package de.bixilon.minosoft.protocol.packets.clientbound.play; package de.bixilon.minosoft.protocol.packets.clientbound.play;
import de.bixilon.minosoft.data.entities.entities.Entity; import de.bixilon.minosoft.data.entities.entities.Entity;
import de.bixilon.minosoft.data.mappings.MobEffect; import de.bixilon.minosoft.data.mappings.StatusEffect;
import de.bixilon.minosoft.protocol.network.Connection; import de.bixilon.minosoft.protocol.network.Connection;
import de.bixilon.minosoft.protocol.packets.ClientboundPacket; import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer; import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.util.logging.Log; import de.bixilon.minosoft.util.logging.Log;
public class PacketRemoveEntityEffect extends ClientboundPacket { public class PacketRemoveEntityStatusEffect extends ClientboundPacket {
int entityId; private int entityId;
MobEffect effect; private StatusEffect effect;
@Override @Override
public boolean read(InByteBuffer buffer) { public boolean read(InByteBuffer buffer) {
this.entityId = buffer.readEntityId(); this.entityId = buffer.readEntityId();
this.effect = buffer.getConnection().getMapping().getMobEffectRegistry().get(buffer.readByte()); this.effect = buffer.getConnection().getMapping().getStatusEffectRegistry().get(buffer.readByte());
return true; return true;
} }
@ -51,7 +51,7 @@ public class PacketRemoveEntityEffect extends ClientboundPacket {
return this.entityId; return this.entityId;
} }
public MobEffect getEffect() { public StatusEffect getEffect() {
return this.effect; return this.effect;
} }
} }

View File

@ -155,7 +155,7 @@ public class PacketTypes {
PLAY_PLAYER_POSITION_AND_ROTATION(PacketPlayerPositionAndRotation::new), PLAY_PLAYER_POSITION_AND_ROTATION(PacketPlayerPositionAndRotation::new),
PLAY_UNLOCK_RECIPES(PacketUnlockRecipes::new), PLAY_UNLOCK_RECIPES(PacketUnlockRecipes::new),
PLAY_DESTROY_ENTITIES(PacketDestroyEntity::new), PLAY_DESTROY_ENTITIES(PacketDestroyEntity::new),
PLAY_REMOVE_ENTITY_EFFECT(PacketRemoveEntityEffect::new), PLAY_REMOVE_ENTITY_EFFECT(PacketRemoveEntityStatusEffect::new),
PLAY_RESOURCE_PACK_SEND(PacketResourcePackSend::new), PLAY_RESOURCE_PACK_SEND(PacketResourcePackSend::new),
PLAY_RESPAWN(PacketRespawn::new, false), PLAY_RESPAWN(PacketRespawn::new, false),
PLAY_ENTITY_HEAD_ROTATION(PacketEntityHeadRotation::new), PLAY_ENTITY_HEAD_ROTATION(PacketEntityHeadRotation::new),