Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-25 15:50:14 +01:00
Merge remote-tracking branch 'upstream/feature/1.20.5' into feature/1.20.5
Dieser Commit ist enthalten in:
Commit
8ab0921448
@ -56,7 +56,7 @@ public final class EntityDefinitions {
|
||||
public static final EntityDefinition<AreaEffectCloudEntity> AREA_EFFECT_CLOUD;
|
||||
public static final EntityDefinition<ArmadilloEntity> ARMADILLO;
|
||||
public static final EntityDefinition<ArmorStandEntity> ARMOR_STAND;
|
||||
public static final EntityDefinition<TippedArrowEntity> ARROW;
|
||||
public static final EntityDefinition<ArrowEntity> ARROW;
|
||||
public static final EntityDefinition<AxolotlEntity> AXOLOTL;
|
||||
public static final EntityDefinition<BatEntity> BAT;
|
||||
public static final EntityDefinition<BeeEntity> BEE;
|
||||
@ -378,10 +378,10 @@ public final class EntityDefinitions {
|
||||
.addTranslator(MetadataType.BYTE, AbstractArrowEntity::setArrowFlags)
|
||||
.addTranslator(null) // "Piercing level"
|
||||
.build();
|
||||
ARROW = EntityDefinition.inherited(TippedArrowEntity::new, abstractArrowBase)
|
||||
ARROW = EntityDefinition.inherited(ArrowEntity::new, abstractArrowBase)
|
||||
.type(EntityType.ARROW)
|
||||
.heightAndWidth(0.25f)
|
||||
.addTranslator(MetadataType.INT, TippedArrowEntity::setPotionEffectColor)
|
||||
.addTranslator(MetadataType.INT, ArrowEntity::setPotionEffectColor)
|
||||
.build();
|
||||
SPECTRAL_ARROW = EntityDefinition.inherited(abstractArrowBase.factory(), abstractArrowBase)
|
||||
.type(EntityType.SPECTRAL_ARROW)
|
||||
@ -454,8 +454,7 @@ public final class EntityDefinitions {
|
||||
EntityDefinition<LivingEntity> livingEntityBase = EntityDefinition.inherited(LivingEntity::new, entityBase)
|
||||
.addTranslator(MetadataType.BYTE, LivingEntity::setLivingEntityFlags)
|
||||
.addTranslator(MetadataType.FLOAT, LivingEntity::setHealth)
|
||||
.addTranslator(MetadataType.INT,
|
||||
(livingEntity, entityMetadata) -> livingEntity.getDirtyMetadata().put(EntityDataTypes.EFFECT_COLOR, entityMetadata.getValue()))
|
||||
.addTranslator(MetadataType.PARTICLES, LivingEntity::setParticles)
|
||||
.addTranslator(MetadataType.BOOLEAN,
|
||||
(livingEntity, entityMetadata) -> livingEntity.getDirtyMetadata().put(EntityDataTypes.EFFECT_AMBIENCE, (byte) (((BooleanEntityMetadata) entityMetadata).getPrimitiveValue() ? 1 : 0)))
|
||||
.addTranslator(null) // Arrow count
|
||||
|
@ -34,12 +34,9 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEnt
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Internally this is known as TippedArrowEntity but is used with tipped arrows and normal arrows
|
||||
*/
|
||||
public class TippedArrowEntity extends AbstractArrowEntity {
|
||||
public class ArrowEntity extends AbstractArrowEntity {
|
||||
|
||||
public TippedArrowEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
||||
public ArrowEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
||||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
@ -55,9 +55,13 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.FloatEntityMetadata;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.level.particle.EntityEffectParticleData;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.level.particle.Particle;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.level.particle.ParticleType;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -152,6 +156,37 @@ public class LivingEntity extends Entity {
|
||||
session.sendUpstreamPacket(attributesPacket);
|
||||
}
|
||||
|
||||
// TODO: support all particle types
|
||||
public void setParticles(ObjectEntityMetadata<List<Particle>> entityMetadata) {
|
||||
List<Particle> particles = entityMetadata.getValue();
|
||||
float r = 0f;
|
||||
float g = 0f;
|
||||
float b = 0f;
|
||||
|
||||
int count = 0;
|
||||
for (Particle particle : particles) {
|
||||
if (particle.getType() != ParticleType.ENTITY_EFFECT) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int color = ((EntityEffectParticleData) particle.getData()).getColor();
|
||||
r += ((color >> 16) & 0xFF) / 255f;
|
||||
g += ((color >> 8) & 0xFF) / 255f;
|
||||
b += ((color) & 0xFF) / 255f;
|
||||
count++;
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
if (count > 0) {
|
||||
r = r / count * 255f;
|
||||
g = g / count * 255f;
|
||||
b = b / count * 255f;
|
||||
result = (int) r << 16 | (int) g << 8 | (int) b;
|
||||
}
|
||||
|
||||
dirtyMetadata.put(EntityDataTypes.EFFECT_COLOR, result);
|
||||
}
|
||||
|
||||
public @Nullable Vector3i setBedPosition(EntityMetadata<Optional<Vector3i>, ?> entityMetadata) {
|
||||
Optional<Vector3i> optionalPos = entityMetadata.getValue();
|
||||
if (optionalPos.isPresent()) {
|
||||
|
@ -91,15 +91,6 @@ public enum Potion {
|
||||
return new PotionContents(this.ordinal(), -1, Int2ObjectMaps.emptyMap());
|
||||
}
|
||||
|
||||
public static @Nullable Potion getByJavaIdentifier(String javaIdentifier) {
|
||||
for (Potion potion : VALUES) {
|
||||
if (potion.javaIdentifier.equals(javaIdentifier)) {
|
||||
return potion;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static @Nullable Potion getByBedrockId(int bedrockId) {
|
||||
for (Potion potion : VALUES) {
|
||||
if (potion.bedrockId == bedrockId) {
|
||||
|
@ -99,15 +99,6 @@ public enum TippedArrowPotion {
|
||||
return VALUES[id];
|
||||
}
|
||||
|
||||
public static @Nullable TippedArrowPotion getByJavaIdentifier(String javaIdentifier) {
|
||||
for (TippedArrowPotion potion : VALUES) {
|
||||
if (potion.javaIdentifier.equals(javaIdentifier)) {
|
||||
return potion;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static @Nullable TippedArrowPotion getByBedrockId(int bedrockId) {
|
||||
for (TippedArrowPotion potion : VALUES) {
|
||||
if (potion.bedrockId == bedrockId) {
|
||||
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2023 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.geyser.item;
|
||||
|
||||
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DyedItemColor;
|
||||
|
||||
public interface DyeableLeatherItem {
|
||||
|
||||
static void translateComponentsToBedrock(DataComponents components, BedrockItemBuilder builder) {
|
||||
DyedItemColor dyedItemColor = components.get(DataComponentType.DYED_COLOR);
|
||||
if (dyedItemColor == null) {
|
||||
return;
|
||||
}
|
||||
builder.putInt("customColor", dyedItemColor.getRgb());
|
||||
}
|
||||
}
|
@ -256,20 +256,20 @@ public final class Items {
|
||||
public static final Item GREEN_WOOL = register(new BlockItem("green_wool", builder()));
|
||||
public static final Item RED_WOOL = register(new BlockItem("red_wool", builder()));
|
||||
public static final Item BLACK_WOOL = register(new BlockItem("black_wool", builder()));
|
||||
public static final Item DANDELION = register(new FlowerItem("dandelion", builder()));
|
||||
public static final Item POPPY = register(new FlowerItem("poppy", builder()));
|
||||
public static final Item BLUE_ORCHID = register(new FlowerItem("blue_orchid", builder()));
|
||||
public static final Item ALLIUM = register(new FlowerItem("allium", builder()));
|
||||
public static final Item AZURE_BLUET = register(new FlowerItem("azure_bluet", builder()));
|
||||
public static final Item RED_TULIP = register(new FlowerItem("red_tulip", builder()));
|
||||
public static final Item ORANGE_TULIP = register(new FlowerItem("orange_tulip", builder()));
|
||||
public static final Item WHITE_TULIP = register(new FlowerItem("white_tulip", builder()));
|
||||
public static final Item PINK_TULIP = register(new FlowerItem("pink_tulip", builder()));
|
||||
public static final Item OXEYE_DAISY = register(new FlowerItem("oxeye_daisy", builder()));
|
||||
public static final Item CORNFLOWER = register(new FlowerItem("cornflower", builder()));
|
||||
public static final Item LILY_OF_THE_VALLEY = register(new FlowerItem("lily_of_the_valley", builder()));
|
||||
public static final Item WITHER_ROSE = register(new FlowerItem("wither_rose", builder()));
|
||||
public static final Item TORCHFLOWER = register(new FlowerItem("torchflower", builder()));
|
||||
public static final Item DANDELION = register(new BlockItem("dandelion", builder()));
|
||||
public static final Item POPPY = register(new BlockItem("poppy", builder()));
|
||||
public static final Item BLUE_ORCHID = register(new BlockItem("blue_orchid", builder()));
|
||||
public static final Item ALLIUM = register(new BlockItem("allium", builder()));
|
||||
public static final Item AZURE_BLUET = register(new BlockItem("azure_bluet", builder()));
|
||||
public static final Item RED_TULIP = register(new BlockItem("red_tulip", builder()));
|
||||
public static final Item ORANGE_TULIP = register(new BlockItem("orange_tulip", builder()));
|
||||
public static final Item WHITE_TULIP = register(new BlockItem("white_tulip", builder()));
|
||||
public static final Item PINK_TULIP = register(new BlockItem("pink_tulip", builder()));
|
||||
public static final Item OXEYE_DAISY = register(new BlockItem("oxeye_daisy", builder()));
|
||||
public static final Item CORNFLOWER = register(new BlockItem("cornflower", builder()));
|
||||
public static final Item LILY_OF_THE_VALLEY = register(new BlockItem("lily_of_the_valley", builder()));
|
||||
public static final Item WITHER_ROSE = register(new BlockItem("wither_rose", builder()));
|
||||
public static final Item TORCHFLOWER = register(new BlockItem("torchflower", builder()));
|
||||
public static final Item PITCHER_PLANT = register(new BlockItem("pitcher_plant", builder()));
|
||||
public static final Item SPORE_BLOSSOM = register(new BlockItem("spore_blossom", builder()));
|
||||
public static final Item BROWN_MUSHROOM = register(new BlockItem("brown_mushroom", builder()));
|
||||
@ -337,7 +337,7 @@ public final class Items {
|
||||
public static final Item PURPUR_PILLAR = register(new BlockItem("purpur_pillar", builder()));
|
||||
public static final Item PURPUR_STAIRS = register(new BlockItem("purpur_stairs", builder()));
|
||||
public static final Item SPAWNER = register(new BlockItem("spawner", builder()));
|
||||
public static final Item CHEST = register(new ChestItem("chest", builder()));
|
||||
public static final Item CHEST = register(new BlockItem("chest", builder()));
|
||||
public static final Item CRAFTING_TABLE = register(new BlockItem("crafting_table", builder()));
|
||||
public static final Item FARMLAND = register(new BlockItem("farmland", builder()));
|
||||
public static final Item FURNACE = register(new BlockItem("furnace", builder()));
|
||||
@ -419,7 +419,7 @@ public final class Items {
|
||||
public static final Item END_STONE_BRICKS = register(new BlockItem("end_stone_bricks", builder()));
|
||||
public static final Item DRAGON_EGG = register(new BlockItem("dragon_egg", builder()));
|
||||
public static final Item SANDSTONE_STAIRS = register(new BlockItem("sandstone_stairs", builder()));
|
||||
public static final Item ENDER_CHEST = register(new ChestItem("ender_chest", builder()));
|
||||
public static final Item ENDER_CHEST = register(new BlockItem("ender_chest", builder()));
|
||||
public static final Item EMERALD_BLOCK = register(new BlockItem("emerald_block", builder()));
|
||||
public static final Item OAK_STAIRS = register(new BlockItem("oak_stairs", builder()));
|
||||
public static final Item SPRUCE_STAIRS = register(new BlockItem("spruce_stairs", builder()));
|
||||
@ -716,7 +716,7 @@ public final class Items {
|
||||
public static final Item SCULK_SENSOR = register(new BlockItem("sculk_sensor", builder()));
|
||||
public static final Item CALIBRATED_SCULK_SENSOR = register(new BlockItem("calibrated_sculk_sensor", builder()));
|
||||
public static final Item TRIPWIRE_HOOK = register(new BlockItem("tripwire_hook", builder()));
|
||||
public static final Item TRAPPED_CHEST = register(new ChestItem("trapped_chest", builder()));
|
||||
public static final Item TRAPPED_CHEST = register(new BlockItem("trapped_chest", builder()));
|
||||
public static final Item TNT = register(new BlockItem("tnt", builder()));
|
||||
public static final Item REDSTONE_LAMP = register(new BlockItem("redstone_lamp", builder()));
|
||||
public static final Item NOTE_BLOCK = register(new BlockItem("note_block", builder()));
|
||||
@ -894,10 +894,10 @@ public final class Items {
|
||||
public static final Item WHEAT_SEEDS = register(new BlockItem("wheat_seeds", builder()));
|
||||
public static final Item WHEAT = register(new Item("wheat", builder()));
|
||||
public static final Item BREAD = register(new Item("bread", builder()));
|
||||
public static final Item LEATHER_HELMET = register(new ArmorItem("leather_helmet", ArmorMaterial.LEATHER, builder().stackSize(1).maxDamage(55)));
|
||||
public static final Item LEATHER_CHESTPLATE = register(new ArmorItem("leather_chestplate", ArmorMaterial.LEATHER, builder().stackSize(1).maxDamage(80)));
|
||||
public static final Item LEATHER_LEGGINGS = register(new ArmorItem("leather_leggings", ArmorMaterial.LEATHER, builder().stackSize(1).maxDamage(75)));
|
||||
public static final Item LEATHER_BOOTS = register(new ArmorItem("leather_boots", ArmorMaterial.LEATHER, builder().stackSize(1).maxDamage(65)));
|
||||
public static final Item LEATHER_HELMET = register(new DyeableArmorItem("leather_helmet", ArmorMaterial.LEATHER, builder().stackSize(1).maxDamage(55)));
|
||||
public static final Item LEATHER_CHESTPLATE = register(new DyeableArmorItem("leather_chestplate", ArmorMaterial.LEATHER, builder().stackSize(1).maxDamage(80)));
|
||||
public static final Item LEATHER_LEGGINGS = register(new DyeableArmorItem("leather_leggings", ArmorMaterial.LEATHER, builder().stackSize(1).maxDamage(75)));
|
||||
public static final Item LEATHER_BOOTS = register(new DyeableArmorItem("leather_boots", ArmorMaterial.LEATHER, builder().stackSize(1).maxDamage(65)));
|
||||
public static final Item CHAINMAIL_HELMET = register(new ArmorItem("chainmail_helmet", ArmorMaterial.CHAINMAIL, builder().stackSize(1).maxDamage(165)));
|
||||
public static final Item CHAINMAIL_CHESTPLATE = register(new ArmorItem("chainmail_chestplate", ArmorMaterial.CHAINMAIL, builder().stackSize(1).maxDamage(240)));
|
||||
public static final Item CHAINMAIL_LEGGINGS = register(new ArmorItem("chainmail_leggings", ArmorMaterial.CHAINMAIL, builder().stackSize(1).maxDamage(225)));
|
||||
@ -1165,7 +1165,7 @@ public final class Items {
|
||||
public static final Item IRON_HORSE_ARMOR = register(new ArmorItem("iron_horse_armor", ArmorMaterial.IRON, builder().stackSize(1)));
|
||||
public static final Item GOLDEN_HORSE_ARMOR = register(new ArmorItem("golden_horse_armor", ArmorMaterial.GOLD, builder().stackSize(1)));
|
||||
public static final Item DIAMOND_HORSE_ARMOR = register(new ArmorItem("diamond_horse_armor", ArmorMaterial.DIAMOND, builder().stackSize(1)));
|
||||
public static final Item LEATHER_HORSE_ARMOR = register(new ArmorItem("leather_horse_armor", ArmorMaterial.LEATHER, builder().stackSize(1)));
|
||||
public static final Item LEATHER_HORSE_ARMOR = register(new DyeableArmorItem("leather_horse_armor", ArmorMaterial.LEATHER, builder().stackSize(1)));
|
||||
public static final Item LEAD = register(new Item("lead", builder()));
|
||||
public static final Item NAME_TAG = register(new Item("name_tag", builder()));
|
||||
public static final Item COMMAND_BLOCK_MINECART = register(new Item("command_block_minecart", builder().stackSize(1)));
|
||||
@ -1240,7 +1240,7 @@ public final class Items {
|
||||
public static final Item GUSTER_BANNER_PATTERN = register(new Item("guster_banner_pattern", builder().stackSize(1)));
|
||||
public static final Item GOAT_HORN = register(new GoatHornItem("goat_horn", builder().stackSize(1)));
|
||||
public static final Item COMPOSTER = register(new BlockItem("composter", builder()));
|
||||
public static final Item BARREL = register(new ChestItem("barrel", builder()));
|
||||
public static final Item BARREL = register(new BlockItem("barrel", builder()));
|
||||
public static final Item SMOKER = register(new BlockItem("smoker", builder()));
|
||||
public static final Item BLAST_FURNACE = register(new BlockItem("blast_furnace", builder()));
|
||||
public static final Item CARTOGRAPHY_TABLE = register(new BlockItem("cartography_table", builder()));
|
||||
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2023 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.geyser.item.type;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
|
||||
|
||||
@Deprecated
|
||||
public class ChestItem extends BlockItem {
|
||||
|
||||
public ChestItem(String javaIdentifier, Builder builder) {
|
||||
super(javaIdentifier, builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponents components, @NonNull BedrockItemBuilder builder) {
|
||||
super.translateComponentsToBedrock(session, components, builder);
|
||||
}
|
||||
}
|
@ -27,12 +27,13 @@ package org.geysermc.geyser.item.type;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.item.ArmorMaterial;
|
||||
import org.geysermc.geyser.item.DyeableLeatherItem;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DyedItemColor;
|
||||
|
||||
public class DyeableArmorItem extends ArmorItem implements DyeableLeatherItem {
|
||||
public class DyeableArmorItem extends ArmorItem {
|
||||
public DyeableArmorItem(String javaIdentifier, ArmorMaterial material, Builder builder) {
|
||||
super(javaIdentifier, material, builder);
|
||||
}
|
||||
@ -41,6 +42,11 @@ public class DyeableArmorItem extends ArmorItem implements DyeableLeatherItem {
|
||||
public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponents components, @NonNull BedrockItemBuilder builder) {
|
||||
super.translateComponentsToBedrock(session, components, builder);
|
||||
|
||||
DyeableLeatherItem.translateComponentsToBedrock(components, builder);
|
||||
// Note that this is handled as of 1.20.5 in the ItemColors class.
|
||||
// But horse leather armor and body leather armor are now both armor items. So it works!
|
||||
DyedItemColor dyedItemColor = components.get(DataComponentType.DYED_COLOR);
|
||||
if (dyedItemColor != null) {
|
||||
builder.putInt("customColor", dyedItemColor.getRgb());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2023 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.geyser.item.type;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.item.DyeableLeatherItem;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
|
||||
|
||||
public class DyeableHorseArmorItem extends Item implements DyeableLeatherItem {
|
||||
public DyeableHorseArmorItem(String javaIdentifier, Builder builder) {
|
||||
super(javaIdentifier, builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponents components, @NonNull BedrockItemBuilder builder) {
|
||||
super.translateComponentsToBedrock(session, components, builder);
|
||||
|
||||
DyeableLeatherItem.translateComponentsToBedrock(components, builder);
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2023 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.geyser.item.type;
|
||||
|
||||
// If blocks are implemented, then this class is not needed.
|
||||
public class FlowerItem extends BlockItem {
|
||||
public FlowerItem(String javaIdentifier, Builder builder) {
|
||||
super(javaIdentifier, builder);
|
||||
}
|
||||
}
|
@ -35,20 +35,7 @@ import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponen
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.Instrument;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GoatHornItem extends Item {
|
||||
private static final List<String> INSTRUMENTS = List.of(
|
||||
"ponder_goat_horn",
|
||||
"sing_goat_horn",
|
||||
"seek_goat_horn",
|
||||
"feel_goat_horn",
|
||||
"admire_goat_horn",
|
||||
"call_goat_horn",
|
||||
"yearn_goat_horn",
|
||||
"dream_goat_horn" // Called "Resist" on Bedrock 1.19.0 due to https://bugs.mojang.com/browse/MCPE-155059
|
||||
);
|
||||
|
||||
public GoatHornItem(String javaIdentifier, Builder builder) {
|
||||
super(javaIdentifier, builder);
|
||||
}
|
||||
@ -60,19 +47,8 @@ public class GoatHornItem extends Item {
|
||||
return builder;
|
||||
}
|
||||
Holder<Instrument> instrument = components.get(DataComponentType.INSTRUMENT);
|
||||
// TODO registry
|
||||
if (instrument != null) {
|
||||
// Drop the Minecraft namespace if applicable
|
||||
// if (instrument.startsWith("minecraft:")) {
|
||||
// instrument = instrument.substring("minecraft:".length());
|
||||
// }
|
||||
//
|
||||
// int damage = INSTRUMENTS.indexOf(instrument);
|
||||
// if (damage == -1) {
|
||||
// damage = 0;
|
||||
// GeyserImpl.getInstance().getLogger().debug("Unknown goat horn instrument: " + instrumentTag.getValue());
|
||||
// }
|
||||
// builder.damage(damage);
|
||||
if (instrument != null && instrument.isId()) {
|
||||
builder.damage(instrument.id());
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
@ -148,9 +148,10 @@ public class ItemMappings implements DefinitionRegistry<ItemDefinition> {
|
||||
}
|
||||
} else {
|
||||
if (!(mapping.getBedrockData() == data.getDamage() ||
|
||||
// Make exceptions for potions, tipped arrows, firework stars, and goat horns, whose damage values can vary
|
||||
// Make exceptions for potions, tipped arrows, firework stars, goat horns, and suspicious stews, whose damage values can vary
|
||||
(mapping.getJavaItem() instanceof PotionItem || mapping.getJavaItem() == Items.ARROW
|
||||
|| mapping.getJavaItem() == Items.FIREWORK_STAR || mapping.getJavaItem() == Items.GOAT_HORN))) {
|
||||
|| mapping.getJavaItem() == Items.FIREWORK_STAR || mapping.getJavaItem() == Items.GOAT_HORN
|
||||
|| mapping.getJavaItem() == Items.SUSPICIOUS_STEW))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public final class ItemTranslator {
|
||||
/**
|
||||
* The order of these slots is their display order on Java Edition clients
|
||||
*/
|
||||
private static final String[] ALL_SLOTS = new String[]{"mainhand", "offhand", "feet", "legs", "chest", "head"};
|
||||
private static final ItemAttributeModifiers.EquipmentSlotGroup[] ALL_SLOTS = ItemAttributeModifiers.EquipmentSlotGroup.values();
|
||||
private static final DecimalFormat ATTRIBUTE_FORMAT = new DecimalFormat("0.#####");
|
||||
|
||||
private ItemTranslator() {
|
||||
@ -93,7 +93,8 @@ public final class ItemTranslator {
|
||||
|
||||
NbtMap nbt = data.getTag();
|
||||
if (nbt != null && !nbt.isEmpty()) {
|
||||
DataComponents components = new DataComponents(new HashMap<>());
|
||||
// translateToJava may have added components
|
||||
DataComponents components = itemStack.getComponents() == null ? new DataComponents(new HashMap<>()) : itemStack.getComponents();
|
||||
javaItem.translateNbtToJava(nbt, components, bedrockItem);
|
||||
if (!components.getDataComponents().isEmpty()) {
|
||||
itemStack.setComponents(components);
|
||||
@ -127,7 +128,7 @@ public final class ItemTranslator {
|
||||
.build();
|
||||
}
|
||||
|
||||
private static ItemData.@NonNull Builder translateToBedrock(GeyserSession session, Item javaItem, ItemMapping bedrockItem, int count, DataComponents components) {
|
||||
private static ItemData.@NonNull Builder translateToBedrock(GeyserSession session, Item javaItem, ItemMapping bedrockItem, int count, @Nullable DataComponents components) {
|
||||
BedrockItemBuilder nbtBuilder = new BedrockItemBuilder();
|
||||
|
||||
if (components != null) {
|
||||
@ -207,8 +208,8 @@ public final class ItemTranslator {
|
||||
ItemAttributeModifiers.EquipmentSlotGroup slotGroup = entry.getSlot();
|
||||
if (slotGroup == ItemAttributeModifiers.EquipmentSlotGroup.ANY) {
|
||||
// modifier applies to all slots implicitly
|
||||
for (String slot : ALL_SLOTS) { // TODO SOMEONE LOOK HERE PLZ
|
||||
//slotsToModifiers.computeIfAbsent(slot, s -> new ArrayList<>()).add(loreEntry);
|
||||
for (var slot : ALL_SLOTS) {
|
||||
slotsToModifiers.computeIfAbsent(slot, s -> new ArrayList<>()).add(loreEntry);
|
||||
}
|
||||
} else {
|
||||
// modifier applies to only the specified slot
|
||||
@ -217,7 +218,7 @@ public final class ItemTranslator {
|
||||
}
|
||||
|
||||
// iterate through the small array, not the map, so that ordering matches Java Edition
|
||||
for (String slot : ALL_SLOTS) {
|
||||
for (var slot : ALL_SLOTS) {
|
||||
List<String> modifierStrings = slotsToModifiers.get(slot);
|
||||
if (modifierStrings == null || modifierStrings.isEmpty()) {
|
||||
continue;
|
||||
@ -274,10 +275,10 @@ public final class ItemTranslator {
|
||||
return MessageTranslator.convertMessage(attributeComponent, language);
|
||||
}
|
||||
|
||||
private static void addAdvancedTooltips(DataComponents components, BedrockItemBuilder builder, Item item, String language) {
|
||||
private static void addAdvancedTooltips(@Nullable DataComponents components, BedrockItemBuilder builder, Item item, String language) {
|
||||
int maxDurability = item.maxDamage();
|
||||
|
||||
if (maxDurability != 0) {
|
||||
if (maxDurability != 0 && components != null) {
|
||||
Integer durabilityComponent = components.get(DataComponentType.DAMAGE);
|
||||
if (durabilityComponent != null) {
|
||||
int durability = maxDurability - durabilityComponent;
|
||||
@ -299,7 +300,7 @@ public final class ItemTranslator {
|
||||
Component component = Component.text()
|
||||
.resetStyle()
|
||||
.color(NamedTextColor.DARK_GRAY)
|
||||
.append(Component.translatable("item.nbt_tags", // TODO
|
||||
.append(Component.translatable("item.components",
|
||||
Component.text(components.getDataComponents().size())))
|
||||
.build();
|
||||
builder.getOrCreateLore().add(MessageTranslator.convertMessage(component, language));
|
||||
@ -394,7 +395,7 @@ public final class ItemTranslator {
|
||||
customName = components.get(DataComponentType.ITEM_NAME);
|
||||
}
|
||||
if (customName != null) {
|
||||
// Get the translated name and prefix it with a reset char TODO test
|
||||
// Get the translated name and prefix it with a reset char
|
||||
return MessageTranslator.convertMessage(customName, session.locale());
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ protocol-connection = "3.0.0.Beta1-20240411.165033-128"
|
||||
raknet = "1.0.0.CR3-20240416.144209-1"
|
||||
blockstateupdater="1.20.80-20240411.142413-1"
|
||||
mcauthlib = "d9d773e"
|
||||
mcprotocollib = "98410a1" # Revert from jitpack after release
|
||||
mcprotocollib = "400f1b4" # Revert from jitpack after release
|
||||
adventure = "4.14.0"
|
||||
adventure-platform = "4.3.0"
|
||||
junit = "5.9.2"
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren