forked from GeyserMC/Geyser
Make crossbows prettier (#1359)
- Fix crossbow NBT translation - now crossbows will show as loaded - Pillagers now more closely resemble Java Edition pose behavior
This commit is contained in:
parent
59f72d0e65
commit
ec609fa868
3 changed files with 67 additions and 11 deletions
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author GeyserMC
|
||||||
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.geysermc.connector.entity.living.monster.raid;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||||
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
|
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||||
|
import org.geysermc.connector.entity.type.EntityType;
|
||||||
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
|
|
||||||
|
public class PillagerEntity extends AbstractIllagerEntity {
|
||||||
|
|
||||||
|
public PillagerEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
|
||||||
|
super(entityId, geyserId, entityType, position, motion, rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
|
||||||
|
if (entityMetadata.getId() == 16) {
|
||||||
|
// Java Edition always has the Pillager entity as positioning the crossbow
|
||||||
|
metadata.getFlags().setFlag(EntityFlag.USING_ITEM, true);
|
||||||
|
metadata.getFlags().setFlag(EntityFlag.CHARGED, true);
|
||||||
|
}
|
||||||
|
super.updateBedrockMetadata(entityMetadata, session);
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,6 +34,7 @@ import org.geysermc.connector.entity.living.animal.tameable.*;
|
||||||
import org.geysermc.connector.entity.living.merchant.*;
|
import org.geysermc.connector.entity.living.merchant.*;
|
||||||
import org.geysermc.connector.entity.living.monster.*;
|
import org.geysermc.connector.entity.living.monster.*;
|
||||||
import org.geysermc.connector.entity.living.monster.raid.AbstractIllagerEntity;
|
import org.geysermc.connector.entity.living.monster.raid.AbstractIllagerEntity;
|
||||||
|
import org.geysermc.connector.entity.living.monster.raid.PillagerEntity;
|
||||||
import org.geysermc.connector.entity.living.monster.raid.RaidParticipantEntity;
|
import org.geysermc.connector.entity.living.monster.raid.RaidParticipantEntity;
|
||||||
import org.geysermc.connector.entity.living.monster.raid.SpellcasterIllagerEntity;
|
import org.geysermc.connector.entity.living.monster.raid.SpellcasterIllagerEntity;
|
||||||
|
|
||||||
|
@ -90,7 +91,7 @@ public enum EntityType {
|
||||||
ENDERMITE(MonsterEntity.class, 55, 0.3f, 0.4f),
|
ENDERMITE(MonsterEntity.class, 55, 0.3f, 0.4f),
|
||||||
AGENT(Entity.class, 56, 0f),
|
AGENT(Entity.class, 56, 0f),
|
||||||
VINDICATOR(AbstractIllagerEntity.class, 57, 1.8f, 0.6f, 0.6f, 1.62f),
|
VINDICATOR(AbstractIllagerEntity.class, 57, 1.8f, 0.6f, 0.6f, 1.62f),
|
||||||
PILLAGER(AbstractIllagerEntity.class, 114, 1.8f, 0.6f, 0.6f, 1.62f),
|
PILLAGER(PillagerEntity.class, 114, 1.8f, 0.6f, 0.6f, 1.62f),
|
||||||
WANDERING_TRADER(AbstractMerchantEntity.class, 118, 1.8f, 0.6f, 0.6f, 1.62f),
|
WANDERING_TRADER(AbstractMerchantEntity.class, 118, 1.8f, 0.6f, 0.6f, 1.62f),
|
||||||
PHANTOM(FlyingEntity.class, 58, 0.5f, 0.9f, 0.9f, 0.6f),
|
PHANTOM(FlyingEntity.class, 58, 0.5f, 0.9f, 0.9f, 0.6f),
|
||||||
RAVAGER(RaidParticipantEntity.class, 59, 1.9f, 1.2f),
|
RAVAGER(RaidParticipantEntity.class, 59, 1.9f, 1.2f),
|
||||||
|
|
|
@ -25,14 +25,15 @@
|
||||||
|
|
||||||
package org.geysermc.connector.network.translators.item.translators.nbt;
|
package org.geysermc.connector.network.translators.item.translators.nbt;
|
||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.*;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.ItemRemapper;
|
import org.geysermc.connector.network.translators.ItemRemapper;
|
||||||
import org.geysermc.connector.network.translators.item.NbtItemStackTranslator;
|
|
||||||
import org.geysermc.connector.network.translators.item.ItemEntry;
|
import org.geysermc.connector.network.translators.item.ItemEntry;
|
||||||
|
import org.geysermc.connector.network.translators.item.ItemRegistry;
|
||||||
|
import org.geysermc.connector.network.translators.item.ItemTranslator;
|
||||||
|
import org.geysermc.connector.network.translators.item.NbtItemStackTranslator;
|
||||||
|
|
||||||
@ItemRemapper
|
@ItemRemapper
|
||||||
public class CrossbowTranslator extends NbtItemStackTranslator {
|
public class CrossbowTranslator extends NbtItemStackTranslator {
|
||||||
|
@ -44,12 +45,17 @@ public class CrossbowTranslator extends NbtItemStackTranslator {
|
||||||
if (!chargedProjectiles.getValue().isEmpty()) {
|
if (!chargedProjectiles.getValue().isEmpty()) {
|
||||||
CompoundTag projectile = (CompoundTag) chargedProjectiles.getValue().get(0);
|
CompoundTag projectile = (CompoundTag) chargedProjectiles.getValue().get(0);
|
||||||
|
|
||||||
CompoundTag newProjectile = new CompoundTag("chargedItem");
|
ItemEntry entry = ItemRegistry.getItemEntry((String) projectile.get("id").getValue());
|
||||||
newProjectile.put(new ByteTag("Count", (byte) projectile.get("Count").getValue()));
|
if (entry == null) return;
|
||||||
newProjectile.put(new StringTag("Name", (String) projectile.get("id").getValue()));
|
CompoundTag tag = projectile.get("tag");
|
||||||
|
ItemStack itemStack = new ItemStack(itemEntry.getJavaId(), (byte) projectile.get("Count").getValue(), tag);
|
||||||
|
ItemData itemData = ItemTranslator.translateToBedrock(session, itemStack);
|
||||||
|
|
||||||
// Not sure what this is for
|
CompoundTag newProjectile = new CompoundTag("chargedItem");
|
||||||
newProjectile.put(new ByteTag("Damage", (byte) 0));
|
newProjectile.put(new ByteTag("Count", (byte) itemData.getCount()));
|
||||||
|
newProjectile.put(new StringTag("Name", ItemRegistry.getBedrockIdentifer(entry)));
|
||||||
|
|
||||||
|
newProjectile.put(new ShortTag("Damage", itemData.getDamage()));
|
||||||
|
|
||||||
itemTag.put(newProjectile);
|
itemTag.put(newProjectile);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue