mirror of
https://github.com/Minestom/Minestom.git
synced 2024-06-26 06:24:54 +02:00
Added EntityPigZombie metadata + itemstack synchronization
This commit is contained in:
parent
27b0238705
commit
18a1e0b29b
|
@ -50,7 +50,4 @@ dependencies {
|
|||
api 'net.kyori:text-serializer-gson:3.0.3'
|
||||
api 'net.kyori:text-serializer-plain:3.0.3'
|
||||
|
||||
// Used to parse minecraft anvil world format
|
||||
api 'com.github.Hugobros3:Enklume:bec416b92e'
|
||||
|
||||
}
|
||||
|
|
|
@ -2,11 +2,60 @@ package net.minestom.server.entity.type;
|
|||
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.Position;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class EntityPigZombie extends EntityCreature {
|
||||
|
||||
private boolean baby;
|
||||
private boolean becomingDrowned;
|
||||
|
||||
public EntityPigZombie(Position spawnPosition) {
|
||||
super(EntityType.ZOMBIE_PIGMAN, spawnPosition);
|
||||
setBoundingBox(0.6f, 1.95f, 0.6f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 15);
|
||||
fillMetadataIndex(packet, 17);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 15) {
|
||||
packet.writeByte((byte) 15);
|
||||
packet.writeByte(METADATA_BOOLEAN);
|
||||
packet.writeBoolean(baby);
|
||||
} else if (index == 17) {
|
||||
packet.writeByte((byte) 17);
|
||||
packet.writeByte(METADATA_BOOLEAN);
|
||||
packet.writeBoolean(becomingDrowned);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBaby() {
|
||||
return baby;
|
||||
}
|
||||
|
||||
public void setBaby(boolean baby) {
|
||||
this.baby = baby;
|
||||
sendMetadataIndex(15);
|
||||
}
|
||||
|
||||
public boolean isBecomingDrowned() {
|
||||
return becomingDrowned;
|
||||
}
|
||||
|
||||
public void setBecomingDrowned(boolean becomingDrowned) {
|
||||
this.becomingDrowned = becomingDrowned;
|
||||
sendMetadataIndex(17);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -73,27 +73,29 @@ public class ItemStack implements DataContainer {
|
|||
* Do not take amount and stacking rule in consideration
|
||||
*
|
||||
* @param itemStack The ItemStack to compare to
|
||||
* @return true if both items are similar (without comparing amount)
|
||||
* @return true if both items are similar
|
||||
*/
|
||||
public synchronized boolean isSimilar(ItemStack itemStack) {
|
||||
final String itemDisplayName = itemStack.getDisplayName();
|
||||
final boolean displayNameCheck = (displayName == null && itemDisplayName == null) ||
|
||||
(displayName != null && itemDisplayName != null && displayName.equals(itemDisplayName));
|
||||
synchronized (itemStack) {
|
||||
final String itemDisplayName = itemStack.getDisplayName();
|
||||
final boolean displayNameCheck = (displayName == null && itemDisplayName == null) ||
|
||||
(displayName != null && itemDisplayName != null && displayName.equals(itemDisplayName));
|
||||
|
||||
final Data itemData = itemStack.getData();
|
||||
final boolean dataCheck = (data == null && itemData == null) ||
|
||||
(data != null && itemData != null && data.equals(itemData));
|
||||
final Data itemData = itemStack.getData();
|
||||
final boolean dataCheck = (data == null && itemData == null) ||
|
||||
(data != null && itemData != null && data.equals(itemData));
|
||||
|
||||
return itemStack.getMaterialId() == materialId &&
|
||||
displayNameCheck &&
|
||||
itemStack.isUnbreakable() == unbreakable &&
|
||||
itemStack.getDamage() == damage &&
|
||||
itemStack.enchantmentMap.equals(enchantmentMap) &&
|
||||
itemStack.storedEnchantmentMap.equals(storedEnchantmentMap) &&
|
||||
itemStack.attributes.equals(attributes) &&
|
||||
itemStack.potionTypes.equals(potionTypes) &&
|
||||
itemStack.hideFlag == hideFlag &&
|
||||
dataCheck;
|
||||
return itemStack.getMaterialId() == materialId &&
|
||||
displayNameCheck &&
|
||||
itemStack.isUnbreakable() == unbreakable &&
|
||||
itemStack.getDamage() == damage &&
|
||||
itemStack.enchantmentMap.equals(enchantmentMap) &&
|
||||
itemStack.storedEnchantmentMap.equals(storedEnchantmentMap) &&
|
||||
itemStack.attributes.equals(attributes) &&
|
||||
itemStack.potionTypes.equals(potionTypes) &&
|
||||
itemStack.hideFlag == hideFlag &&
|
||||
dataCheck;
|
||||
}
|
||||
}
|
||||
|
||||
public byte getAmount() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user