mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 17:37:58 -04:00
remove some unused stuff, convert EntityEffectAttributesS2CP to kotlin & refactor
This commit is contained in:
parent
c4c69d8e33
commit
6b2fefea08
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.data.entities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class EntityProperty {
|
||||
private final double value;
|
||||
private final HashMap<UUID, EntityPropertyModifier> modifiers = new HashMap<>();
|
||||
|
||||
public EntityProperty(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public HashMap<UUID, EntityPropertyModifier> getModifiers() {
|
||||
return this.modifiers;
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.data.entities;
|
||||
|
||||
public class EntityPropertyModifier {
|
||||
double amount;
|
||||
|
||||
public EntityPropertyModifier(double amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public double getAmount() {
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
public void setAmount(double amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
package de.bixilon.minosoft.protocol.packets.s2c.play
|
||||
|
||||
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||
import de.bixilon.minosoft.data.mappings.effects.attributes.StatusEffectAttribute
|
||||
import de.bixilon.minosoft.data.mappings.effects.attributes.StatusEffectOperations
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_14W04A
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_21W08A
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import java.util.*
|
||||
|
||||
class EntityEffectAttributesS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
val entityId: Int = buffer.readEntityId()
|
||||
val attributes: Map<ResourceLocation, StatusEffectAttribute>
|
||||
|
||||
init {
|
||||
val attributes: MutableMap<ResourceLocation, StatusEffectAttribute> = mutableMapOf()
|
||||
val count: Int = if (buffer.versionId < V_21W08A) {
|
||||
buffer.readInt()
|
||||
} else {
|
||||
buffer.readVarInt()
|
||||
}
|
||||
for (i in 0 until count) {
|
||||
val key: ResourceLocation = buffer.readResourceLocation()
|
||||
val value: Double = buffer.readDouble() // ToDo: For what is this?
|
||||
val listLength: Int = if (buffer.versionId < V_14W04A) {
|
||||
buffer.readUnsignedShort()
|
||||
} else {
|
||||
buffer.readVarInt()
|
||||
}
|
||||
for (ii in 0 until listLength) {
|
||||
val uuid: UUID = buffer.readUUID()
|
||||
val amount: Double = buffer.readDouble()
|
||||
val operation = StatusEffectOperations[buffer.readUnsignedByte()]
|
||||
// ToDo: modifiers
|
||||
attributes[key] = StatusEffectAttribute("", uuid, amount.toFloat(), operation)
|
||||
}
|
||||
}
|
||||
this.attributes = attributes.toMap()
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, LogLevels.VERBOSE) { "Entity effect attributes (entityId=$entityId, attributes=$attributes)" }
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.protocol.packets.s2c.play;
|
||||
|
||||
import de.bixilon.minosoft.data.entities.EntityProperty;
|
||||
import de.bixilon.minosoft.data.mappings.ResourceLocation;
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket;
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer;
|
||||
import de.bixilon.minosoft.util.logging.Log;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import static de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_14W04A;
|
||||
import static de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_21W08A;
|
||||
|
||||
public class PacketEntityProperties extends PlayS2CPacket {
|
||||
private final HashMap<ResourceLocation, EntityProperty> properties = new HashMap<>();
|
||||
private final int entityId;
|
||||
|
||||
public PacketEntityProperties(PlayInByteBuffer buffer) {
|
||||
this.entityId = buffer.readEntityId();
|
||||
if (buffer.getVersionId() < V_14W04A) {
|
||||
int count = buffer.readInt();
|
||||
for (int i = 0; i < count; i++) {
|
||||
ResourceLocation key = buffer.readResourceLocation();
|
||||
double value = buffer.readDouble();
|
||||
int listLength = buffer.readUnsignedShort();
|
||||
for (int ii = 0; ii < listLength; ii++) {
|
||||
UUID uuid = buffer.readUUID();
|
||||
double amount = buffer.readDouble();
|
||||
ModifierActions operation = ModifierActions.byId(buffer.readUnsignedByte());
|
||||
// ToDo: modifiers
|
||||
}
|
||||
this.properties.put(key, new EntityProperty(value));
|
||||
}
|
||||
return;
|
||||
}
|
||||
int count;
|
||||
if (buffer.getVersionId() < V_21W08A) {
|
||||
count = buffer.readInt();
|
||||
} else {
|
||||
count = buffer.readVarInt();
|
||||
}
|
||||
for (int i = 0; i < count; i++) {
|
||||
ResourceLocation key = buffer.readResourceLocation();
|
||||
double value = buffer.readDouble();
|
||||
int listLength = buffer.readVarInt();
|
||||
for (int ii = 0; ii < listLength; ii++) {
|
||||
UUID uuid = buffer.readUUID();
|
||||
double amount = buffer.readDouble();
|
||||
ModifierActions operation = ModifierActions.byId(buffer.readUnsignedByte());
|
||||
// ToDo: modifiers
|
||||
}
|
||||
this.properties.put(key, new EntityProperty(value));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log() {
|
||||
Log.protocol(String.format("[IN] Received entity properties (entityId=%d)", this.entityId));
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return this.entityId;
|
||||
}
|
||||
|
||||
public enum ModifierActions {
|
||||
ADD,
|
||||
ADD_PERCENT,
|
||||
MULTIPLY;
|
||||
|
||||
private static final ModifierActions[] MODIFIER_ACTIONS = values();
|
||||
|
||||
public static ModifierActions byId(int id) {
|
||||
return MODIFIER_ACTIONS[id];
|
||||
}
|
||||
}
|
||||
}
|
@ -252,7 +252,7 @@ class PacketTypes {
|
||||
PLAY_ITEM_COLLECT_ANIMATION({ ItemCollectAnimationS2CP(it) }),
|
||||
PLAY_ENTITY_TELEPORT({ EntityTeleportS2CP(it) }, isThreadSafe = false),
|
||||
PLAY_ADVANCEMENTS({ PacketAdvancements(it) }),
|
||||
PLAY_ENTITY_PROPERTIES({ PacketEntityProperties(it) }),
|
||||
PLAY_ENTITY_EFFECT_ATTRIBUTES({ EntityEffectAttributesS2CP(it) }),
|
||||
PLAY_ENTITY_STATUS_EFFECT({ EntityStatusEffectS2CP(it) }),
|
||||
PLAY_DECLARE_RECIPES({ PacketDeclareRecipes(it) }),
|
||||
PLAY_TAGS({ TagsS2CP(it) }),
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user