mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-19 15:09:15 +00:00
0.0.59
This commit is contained in:
@@ -89,11 +89,10 @@ public class BukkitFurniture implements Furniture {
|
||||
List<Object> minimizedPackets = new ArrayList<>();
|
||||
List<Collider> colliders = new ArrayList<>();
|
||||
WorldPosition position = position();
|
||||
Integer dyedColor = this.extraData.dyedColor().orElse(null);
|
||||
for (FurnitureElement element : placement.elements()) {
|
||||
int entityId = CoreReflections.instance$Entity$ENTITY_COUNTER.incrementAndGet();
|
||||
fakeEntityIds.add(entityId);
|
||||
element.initPackets(entityId, position, conjugated, dyedColor, packet -> {
|
||||
element.initPackets(this, entityId, conjugated, packet -> {
|
||||
packets.add(packet);
|
||||
if (this.minimized) minimizedPackets.add(packet);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.momirealms.craftengine.bukkit.entity.furniture;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import net.momirealms.craftengine.bukkit.entity.data.ItemDisplayEntityData;
|
||||
import net.momirealms.craftengine.bukkit.item.BukkitItemManager;
|
||||
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||
@@ -8,14 +9,19 @@ import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MEntityType
|
||||
import net.momirealms.craftengine.core.entity.Billboard;
|
||||
import net.momirealms.craftengine.core.entity.ItemDisplayContext;
|
||||
import net.momirealms.craftengine.core.entity.furniture.AbstractFurnitureElement;
|
||||
import net.momirealms.craftengine.core.entity.furniture.Furniture;
|
||||
import net.momirealms.craftengine.core.entity.furniture.FurnitureElement;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.item.data.FireworkExplosion;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.util.AdventureHelper;
|
||||
import net.momirealms.craftengine.core.util.GsonHelper;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.world.WorldPosition;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
@@ -45,16 +51,24 @@ public class BukkitFurnitureElement extends AbstractFurnitureElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initPackets(int entityId, @NotNull WorldPosition position, @NotNull Quaternionf conjugated, Integer dyedColor, Consumer<Object> packets) {
|
||||
public void initPackets(Furniture furniture, int entityId, @NotNull Quaternionf conjugated, Consumer<Object> packets) {
|
||||
WorldPosition position = furniture.position();
|
||||
Vector3f offset = conjugated.transform(new Vector3f(position()));
|
||||
packets.accept(FastNMS.INSTANCE.constructor$ClientboundAddEntityPacket(
|
||||
entityId, UUID.randomUUID(), position.x() + offset.x, position.y() + offset.y, position.z() - offset.z, 0, position.xRot(),
|
||||
MEntityTypes.ITEM_DISPLAY, 0, CoreReflections.instance$Vec3$Zero, 0
|
||||
));
|
||||
packets.accept(FastNMS.INSTANCE.constructor$ClientboundSetEntityDataPacket(entityId, getCachedValues(dyedColor)));
|
||||
if (applyDyedColor()) {
|
||||
packets.accept(FastNMS.INSTANCE.constructor$ClientboundSetEntityDataPacket(entityId, getCachedValues(
|
||||
furniture.extraData().dyedColor().orElse(null),
|
||||
furniture.extraData().fireworkExplosionColors().orElse(null)
|
||||
)));
|
||||
} else {
|
||||
packets.accept(FastNMS.INSTANCE.constructor$ClientboundSetEntityDataPacket(entityId, getCachedValues(null, null)));
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized List<Object> getCachedValues(Integer color) {
|
||||
private synchronized List<Object> getCachedValues(@Nullable Integer color, int @Nullable [] colors) {
|
||||
List<Object> cachedValues = new ArrayList<>(this.commonValues);
|
||||
Item<ItemStack> item = BukkitItemManager.instance().createWrappedItem(item(), null);
|
||||
if (item == null) {
|
||||
@@ -64,6 +78,15 @@ public class BukkitFurnitureElement extends AbstractFurnitureElement {
|
||||
if (color != null) {
|
||||
item.dyedColor(color);
|
||||
}
|
||||
if (colors != null) {
|
||||
item.fireworkExplosion(new FireworkExplosion(
|
||||
FireworkExplosion.Shape.SMALL_BALL,
|
||||
new IntArrayList(colors),
|
||||
new IntArrayList(),
|
||||
false,
|
||||
false
|
||||
));
|
||||
}
|
||||
}
|
||||
ItemDisplayEntityData.DisplayedItem.addEntityDataIfNotDefaultValue(item.getLiteralObject(), cachedValues);
|
||||
return cachedValues;
|
||||
|
||||
@@ -29,6 +29,7 @@ public class ComponentTypes {
|
||||
public static final Object PROFILE = getComponentType(ComponentKeys.PROFILE);
|
||||
public static final Object DYED_COLOR = getComponentType(ComponentKeys.DYED_COLOR);
|
||||
public static final Object DEATH_PROTECTION = getComponentType(ComponentKeys.DEATH_PROTECTION);
|
||||
public static final Object FIREWORK_EXPLOSION = getComponentType(ComponentKeys.FIREWORK_EXPLOSION);
|
||||
|
||||
private ComponentTypes() {}
|
||||
|
||||
|
||||
@@ -135,6 +135,7 @@ public class FurnitureItemBehavior extends ItemBehavior {
|
||||
.item(item.copyWithCount(1))
|
||||
.anchorType(anchorType)
|
||||
.dyedColor(item.dyedColor().orElse(null))
|
||||
.fireworkExplosionColors(item.fireworkExplosion().map(explosion -> explosion.colors().toIntArray()).orElse(null))
|
||||
.build(), false);
|
||||
|
||||
FurniturePlaceEvent placeEvent = new FurniturePlaceEvent(bukkitPlayer, bukkitFurniture, furnitureLocation, context.getHand());
|
||||
|
||||
@@ -5,7 +5,7 @@ import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflect
|
||||
import net.momirealms.craftengine.bukkit.util.ItemTags;
|
||||
import net.momirealms.craftengine.core.item.ItemFactory;
|
||||
import net.momirealms.craftengine.core.item.ItemWrapper;
|
||||
import net.momirealms.craftengine.core.item.JukeboxPlayable;
|
||||
import net.momirealms.craftengine.core.item.data.JukeboxPlayable;
|
||||
import net.momirealms.craftengine.core.item.setting.EquipmentData;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.momirealms.craftengine.bukkit.item.factory;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import net.momirealms.craftengine.bukkit.item.ComponentItemWrapper;
|
||||
import net.momirealms.craftengine.bukkit.item.ComponentTypes;
|
||||
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||
@@ -9,18 +10,17 @@ import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MBuiltInReg
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MRegistryOps;
|
||||
import net.momirealms.craftengine.bukkit.util.EnchantmentUtils;
|
||||
import net.momirealms.craftengine.bukkit.util.KeyUtils;
|
||||
import net.momirealms.craftengine.core.item.Enchantment;
|
||||
import net.momirealms.craftengine.core.item.Trim;
|
||||
import net.momirealms.craftengine.core.item.data.Enchantment;
|
||||
import net.momirealms.craftengine.core.item.data.FireworkExplosion;
|
||||
import net.momirealms.craftengine.core.item.data.Trim;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||
import net.momirealms.sparrow.nbt.CompoundTag;
|
||||
import net.momirealms.sparrow.nbt.Tag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
|
||||
public class ComponentItemFactory1_20_5 extends BukkitItemFactory<ComponentItemWrapper> {
|
||||
|
||||
@@ -479,6 +479,41 @@ public class ComponentItemFactory1_20_5 extends BukkitItemFactory<ComponentItemW
|
||||
return Optional.of(new Trim(trimMap.get("pattern"), trimMap.get("material")));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected Optional<FireworkExplosion> fireworkExplosion(ComponentItemWrapper item) {
|
||||
Optional<Object> optionalExplosion = item.getJavaComponent(ComponentTypes.FIREWORK_EXPLOSION);
|
||||
if (optionalExplosion.isEmpty()) return Optional.empty();
|
||||
Map<String, Object> explosions = MiscUtils.castToMap(optionalExplosion.get(), false);
|
||||
FireworkExplosion.Shape shape = Optional.ofNullable(FireworkExplosion.Shape.byName((String) explosions.get("shape"))).orElse(FireworkExplosion.Shape.SMALL_BALL);
|
||||
boolean hasTrail = (boolean) explosions.getOrDefault("has_trail", false);
|
||||
boolean hasTwinkler = (boolean) explosions.getOrDefault("has_twinkle", false);
|
||||
List<Integer> colors = (List<Integer>) Optional.ofNullable(explosions.get("colors")).orElse(new IntArrayList());
|
||||
List<Integer> fadeColors = (List<Integer>) Optional.ofNullable(explosions.get("fade_colors")).orElse(new IntArrayList());
|
||||
return Optional.of(new FireworkExplosion(
|
||||
shape,
|
||||
new IntArrayList(colors),
|
||||
new IntArrayList(fadeColors),
|
||||
hasTrail,
|
||||
hasTwinkler
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fireworkExplosion(ComponentItemWrapper item, FireworkExplosion explosion) {
|
||||
if (explosion == null) {
|
||||
item.resetComponent(ComponentTypes.FIREWORK_EXPLOSION);
|
||||
} else {
|
||||
item.setJavaComponent(ComponentTypes.FIREWORK_EXPLOSION, Map.of(
|
||||
"shape", explosion.shape().getName(),
|
||||
"has_trail", explosion.hasTrail(),
|
||||
"has_twinkle", explosion.hasTwinkle(),
|
||||
"colors", explosion.colors(),
|
||||
"fade_colors", explosion.fadeColors()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ComponentItemWrapper mergeCopy(ComponentItemWrapper item1, ComponentItemWrapper item2) {
|
||||
Object itemStack1 = item1.getLiteralObject();
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.momirealms.craftengine.bukkit.item.factory;
|
||||
|
||||
import net.momirealms.craftengine.bukkit.item.ComponentItemWrapper;
|
||||
import net.momirealms.craftengine.bukkit.item.ComponentTypes;
|
||||
import net.momirealms.craftengine.core.item.JukeboxPlayable;
|
||||
import net.momirealms.craftengine.core.item.data.JukeboxPlayable;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.google.gson.JsonElement;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.craftengine.bukkit.item.ComponentItemWrapper;
|
||||
import net.momirealms.craftengine.bukkit.item.ComponentTypes;
|
||||
import net.momirealms.craftengine.core.item.JukeboxPlayable;
|
||||
import net.momirealms.craftengine.core.item.data.JukeboxPlayable;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.util.AdventureHelper;
|
||||
import net.momirealms.craftengine.core.util.GsonHelper;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package net.momirealms.craftengine.bukkit.item.factory;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import net.momirealms.craftengine.bukkit.item.LegacyItemWrapper;
|
||||
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MBuiltInRegistries;
|
||||
import net.momirealms.craftengine.bukkit.util.KeyUtils;
|
||||
import net.momirealms.craftengine.core.item.Enchantment;
|
||||
import net.momirealms.craftengine.core.item.Trim;
|
||||
import net.momirealms.craftengine.core.item.data.Enchantment;
|
||||
import net.momirealms.craftengine.core.item.data.FireworkExplosion;
|
||||
import net.momirealms.craftengine.core.item.data.Trim;
|
||||
import net.momirealms.craftengine.core.item.modifier.IdModifier;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
@@ -260,6 +262,38 @@ public class UniversalItemFactory extends BukkitItemFactory<LegacyItemWrapper> {
|
||||
item.setTag(trim.pattern(), "Trim", "pattern");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Optional<FireworkExplosion> fireworkExplosion(LegacyItemWrapper item) {
|
||||
Map<String, Object> explosionObj = item.getJavaTag("Explosion");
|
||||
if (explosionObj == null) return Optional.empty();
|
||||
IntArrayList colors = (IntArrayList) explosionObj.get("Colors");
|
||||
IntArrayList fadeColors = (IntArrayList) explosionObj.get("FadeColors");
|
||||
return Optional.of(
|
||||
new FireworkExplosion(
|
||||
FireworkExplosion.Shape.byId((Integer) explosionObj.getOrDefault("Type", 0)),
|
||||
colors == null ? new IntArrayList() : new IntArrayList(colors),
|
||||
fadeColors == null ? new IntArrayList() : new IntArrayList(fadeColors),
|
||||
(boolean) explosionObj.getOrDefault("Trail", false),
|
||||
(boolean) explosionObj.getOrDefault("Flicker", false)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fireworkExplosion(LegacyItemWrapper item, FireworkExplosion explosion) {
|
||||
if (explosion == null) {
|
||||
item.remove("Explosion");
|
||||
} else {
|
||||
item.setTag(Map.of(
|
||||
"Type", explosion.shape().id(),
|
||||
"Colors", explosion.colors(),
|
||||
"FadeColors", explosion.fadeColors(),
|
||||
"Trail", explosion.hasTrail(),
|
||||
"Flicker", explosion.hasTwinkle()
|
||||
), "Explosion");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Optional<Trim> trim(LegacyItemWrapper item) {
|
||||
String material = item.getJavaTag("Trim", "material");
|
||||
|
||||
@@ -758,7 +758,7 @@ public class RecipeEventListener implements Listener {
|
||||
int newItemDamage = Math.max(0, newItem.maxDamage() - remainingDurability);
|
||||
newItem.damage(newItemDamage);
|
||||
inventory.setResult(newItem.getItem());
|
||||
} else if (CoreReflections.clazz$ArmorDyeRecipe.isInstance(mcRecipe)) {
|
||||
} else if (CoreReflections.clazz$ArmorDyeRecipe.isInstance(mcRecipe) || CoreReflections.clazz$FireworkStarFadeRecipe.isInstance(mcRecipe)) {
|
||||
ItemStack[] itemStacks = inventory.getMatrix();
|
||||
for (ItemStack itemStack : itemStacks) {
|
||||
if (itemStack == null) continue;
|
||||
|
||||
@@ -2257,6 +2257,27 @@ public final class CoreReflections {
|
||||
)
|
||||
);
|
||||
|
||||
public static final Class<?> clazz$FireworkRocketRecipe = requireNonNull(
|
||||
BukkitReflectionUtils.findReobfOrMojmapClass(
|
||||
"world.item.crafting.RecipeFireworks",
|
||||
"world.item.crafting.FireworkRocketRecipe"
|
||||
)
|
||||
);
|
||||
|
||||
public static final Class<?> clazz$FireworkStarRecipe = requireNonNull(
|
||||
BukkitReflectionUtils.findReobfOrMojmapClass(
|
||||
"world.item.crafting.RecipeFireworksStar",
|
||||
"world.item.crafting.FireworkStarRecipe"
|
||||
)
|
||||
);
|
||||
|
||||
public static final Class<?> clazz$FireworkStarFadeRecipe = requireNonNull(
|
||||
BukkitReflectionUtils.findReobfOrMojmapClass(
|
||||
"world.item.crafting.RecipeFireworksFade",
|
||||
"world.item.crafting.FireworkStarFadeRecipe"
|
||||
)
|
||||
);
|
||||
|
||||
public static final Class<?> clazz$AnvilMenu = requireNonNull(
|
||||
BukkitReflectionUtils.findReobfOrMojmapClass(
|
||||
"world.inventory.ContainerAnvil",
|
||||
|
||||
@@ -28,7 +28,7 @@ public interface FurnitureElement {
|
||||
|
||||
Vector3f position();
|
||||
|
||||
void initPackets(int entityId, @NotNull WorldPosition position, @NotNull Quaternionf conjugated, @Nullable Integer dyedColor, Consumer<Object> packets);
|
||||
void initPackets(Furniture furniture, int entityId, @NotNull Quaternionf conjugated, Consumer<Object> packets);
|
||||
|
||||
interface Builder {
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.Optional;
|
||||
public class FurnitureExtraData {
|
||||
public static final String ITEM = "item";
|
||||
public static final String DYED_COLOR = "dyed_color";
|
||||
public static final String FIREWORK_EXPLOSION_COLORS = "firework_explosion_colors";
|
||||
public static final String ANCHOR_TYPE = "anchor_type";
|
||||
|
||||
private final CompoundTag data;
|
||||
@@ -45,6 +46,11 @@ public class FurnitureExtraData {
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<int[]> fireworkExplosionColors() {
|
||||
if (this.data.containsKey(FIREWORK_EXPLOSION_COLORS)) return Optional.of(this.data.getIntArray(FIREWORK_EXPLOSION_COLORS));
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public Optional<Integer> dyedColor() {
|
||||
if (this.data.containsKey(DYED_COLOR)) return Optional.of(this.data.getInt(DYED_COLOR));
|
||||
return Optional.empty();
|
||||
@@ -94,6 +100,12 @@ public class FurnitureExtraData {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder fireworkExplosionColors(int[] colors) {
|
||||
if (colors == null) return this;
|
||||
this.data.putIntArray(FIREWORK_EXPLOSION_COLORS, colors);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder anchorType(AnchorType type) {
|
||||
this.data.putInt(ANCHOR_TYPE, type.getId());
|
||||
return this;
|
||||
|
||||
@@ -3,6 +3,10 @@ package net.momirealms.craftengine.core.item;
|
||||
import com.google.gson.JsonElement;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.craftengine.core.item.behavior.ItemBehavior;
|
||||
import net.momirealms.craftengine.core.item.data.Enchantment;
|
||||
import net.momirealms.craftengine.core.item.data.FireworkExplosion;
|
||||
import net.momirealms.craftengine.core.item.data.JukeboxPlayable;
|
||||
import net.momirealms.craftengine.core.item.data.Trim;
|
||||
import net.momirealms.craftengine.core.item.setting.EquipmentData;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.sparrow.nbt.Tag;
|
||||
@@ -107,6 +111,17 @@ public class AbstractItem<W extends ItemWrapper<I>, I> implements Item<I> {
|
||||
return this.factory.dyedColor(this.item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item<I> fireworkExplosion(FireworkExplosion explosion) {
|
||||
this.factory.fireworkExplosion(this.item, explosion);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<FireworkExplosion> fireworkExplosion() {
|
||||
return this.factory.fireworkExplosion(this.item);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Optional<CustomItem<I>> getCustomItem() {
|
||||
|
||||
@@ -2,6 +2,8 @@ package net.momirealms.craftengine.core.item;
|
||||
|
||||
import net.momirealms.craftengine.core.item.behavior.ItemBehavior;
|
||||
import net.momirealms.craftengine.core.item.behavior.ItemBehaviors;
|
||||
import net.momirealms.craftengine.core.item.data.Enchantment;
|
||||
import net.momirealms.craftengine.core.item.data.JukeboxPlayable;
|
||||
import net.momirealms.craftengine.core.item.modifier.*;
|
||||
import net.momirealms.craftengine.core.item.setting.EquipmentData;
|
||||
import net.momirealms.craftengine.core.item.setting.ItemEquipment;
|
||||
|
||||
@@ -27,4 +27,5 @@ public final class ComponentKeys {
|
||||
public static final Key DYED_COLOR = Key.of("minecraft", "dyed_color");
|
||||
public static final Key DEATH_PROTECTION = Key.of("minecraft", "death_protection");
|
||||
public static final Key FOOD = Key.of("minecraft", "food");
|
||||
public static final Key FIREWORK_EXPLOSION = Key.of("minecraft", "firework_explosion");
|
||||
}
|
||||
|
||||
@@ -1,342 +0,0 @@
|
||||
//package net.momirealms.craftengine.core.item;
|
||||
//
|
||||
//import com.google.gson.JsonElement;
|
||||
//import net.momirealms.craftengine.core.item.behavior.ItemBehavior;
|
||||
//import net.momirealms.craftengine.core.util.Key;
|
||||
//
|
||||
//import java.util.List;
|
||||
//import java.util.Optional;
|
||||
//
|
||||
//public class EmptyItem<I> implements Item<I> {
|
||||
// private final I item;
|
||||
//
|
||||
// public EmptyItem(I item) {
|
||||
// this.item = item;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> addEnchantment(Enchantment enchantment) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Optional<CustomItem<I>> getCustomItem() {
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Optional<List<ItemBehavior>> getItemBehavior() {
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isCustomItem() {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isBlockItem() {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Key id() {
|
||||
// return ItemKeys.AIR;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Key vanillaId() {
|
||||
// return ItemKeys.AIR;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Optional<Key> customId() {
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> customId(Key id) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int count() {
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> count(int amount) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> trim(Trim trim) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Optional<Trim> trim() {
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> customModelData(Integer data) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Optional<Integer> customModelData() {
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> damage(Integer data) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Optional<Integer> damage() {
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> repairCost(Integer data) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Optional<Integer> repairCost() {
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> maxDamage(Integer data) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Optional<Integer> maxDamage() {
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> dyedColor(Integer data) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Optional<Integer> dyedColor() {
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> customName(String displayName) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Optional<String> customName() {
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> itemName(String itemName) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Optional<String> itemName() {
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> itemModel(String itemModel) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Optional<String> itemModel() {
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> tooltipStyle(String tooltipStyle) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Optional<String> tooltipStyle() {
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> lore(List<String> lore) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Optional<JukeboxPlayable> jukeboxSong() {
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> jukeboxSong(JukeboxPlayable song) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Optional<EquipmentData> equippable() {
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> equippable(EquipmentData equipmentData) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Optional<List<String>> lore() {
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> unbreakable(boolean unbreakable) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean unbreakable() {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> skull(String data) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Optional<Enchantment> getEnchantment(Key enchantmentId) {
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> setEnchantments(List<Enchantment> enchantments) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> setStoredEnchantments(List<Enchantment> enchantments) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> addStoredEnchantment(Enchantment enchantment) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> itemFlags(List<String> flags) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Object getTag(Object... path) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> setTag(Object value, Object... path) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean hasTag(Object... path) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean removeTag(Object... path) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean hasComponent(Object type) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void removeComponent(Object type) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Object getComponent(Object type) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Object getJavaTypeComponent(Object type) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public JsonElement getJsonTypeComponent(Object type) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setComponent(Object type, Object value) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void resetComponent(Object type) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public I getItem() {
|
||||
// return this.item;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public I load() {
|
||||
// return this.item;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int maxStackSize() {
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> maxStackSize(int amount) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> copyWithCount(int count) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean is(Key itemTag) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Object getLiteralObject() {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Item<I> mergeCopy(Item<?> another) {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void merge(Item<I> another) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public byte[] toByteArray() {
|
||||
// return new byte[0];
|
||||
// }
|
||||
//}
|
||||
@@ -3,6 +3,10 @@ package net.momirealms.craftengine.core.item;
|
||||
import com.google.gson.JsonElement;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.craftengine.core.item.behavior.ItemBehavior;
|
||||
import net.momirealms.craftengine.core.item.data.Enchantment;
|
||||
import net.momirealms.craftengine.core.item.data.FireworkExplosion;
|
||||
import net.momirealms.craftengine.core.item.data.JukeboxPlayable;
|
||||
import net.momirealms.craftengine.core.item.data.Trim;
|
||||
import net.momirealms.craftengine.core.item.modifier.ItemDataModifier;
|
||||
import net.momirealms.craftengine.core.item.setting.EquipmentData;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
@@ -64,6 +68,10 @@ public interface Item<I> {
|
||||
|
||||
Optional<Integer> dyedColor();
|
||||
|
||||
Item<I> fireworkExplosion(FireworkExplosion explosion);
|
||||
|
||||
Optional<FireworkExplosion> fireworkExplosion();
|
||||
|
||||
Item<I> customNameJson(String displayName);
|
||||
|
||||
Item<I> customNameComponent(Component displayName);
|
||||
|
||||
@@ -2,6 +2,10 @@ package net.momirealms.craftengine.core.item;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.craftengine.core.item.data.Enchantment;
|
||||
import net.momirealms.craftengine.core.item.data.FireworkExplosion;
|
||||
import net.momirealms.craftengine.core.item.data.JukeboxPlayable;
|
||||
import net.momirealms.craftengine.core.item.data.Trim;
|
||||
import net.momirealms.craftengine.core.item.setting.EquipmentData;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.util.AdventureHelper;
|
||||
@@ -181,6 +185,10 @@ public abstract class ItemFactory<W extends ItemWrapper<I>, I> {
|
||||
|
||||
protected abstract Optional<EquipmentData> equippable(W item);
|
||||
|
||||
protected abstract void fireworkExplosion(W item, FireworkExplosion explosion);
|
||||
|
||||
protected abstract Optional<FireworkExplosion> fireworkExplosion(W item);
|
||||
|
||||
protected abstract byte[] toByteArray(W item);
|
||||
|
||||
protected abstract void setJavaComponent(W item, Object type, Object value);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.momirealms.craftengine.core.item;
|
||||
package net.momirealms.craftengine.core.item.data;
|
||||
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package net.momirealms.craftengine.core.item.data;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public record FireworkExplosion(Shape shape, IntList colors, IntList fadeColors, boolean hasTrail, boolean hasTwinkle) {
|
||||
|
||||
public enum Shape {
|
||||
SMALL_BALL(0, "small_ball"),
|
||||
LARGE_BALL(1, "large_ball"),
|
||||
STAR(2, "star"),
|
||||
CREEPER(3, "creeper"),
|
||||
BURST(4, "burst");
|
||||
|
||||
private final int id;
|
||||
private final String name;
|
||||
|
||||
Shape(int id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private static final Shape[] BY_ID = values();
|
||||
private static final Map<String, Shape> BY_NAME = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (Shape shape : BY_ID) {
|
||||
BY_NAME.put(shape.getName(), shape);
|
||||
BY_NAME.put(shape.name, shape);
|
||||
}
|
||||
}
|
||||
|
||||
public static Shape byName(String name) {
|
||||
return BY_NAME.get(name);
|
||||
}
|
||||
|
||||
public static Shape byId(int id) {
|
||||
return BY_ID[id];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.momirealms.craftengine.core.item;
|
||||
package net.momirealms.craftengine.core.item.data;
|
||||
|
||||
public record JukeboxPlayable(String song, boolean showInToolTip) {
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.momirealms.craftengine.core.item;
|
||||
package net.momirealms.craftengine.core.item.data;
|
||||
|
||||
public record Trim(String pattern, String material) {
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.momirealms.craftengine.core.item.modifier;
|
||||
|
||||
import net.momirealms.craftengine.core.item.*;
|
||||
import net.momirealms.craftengine.core.item.data.Enchantment;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
import net.momirealms.sparrow.nbt.CompoundTag;
|
||||
import net.momirealms.sparrow.nbt.Tag;
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.momirealms.craftengine.core.item.modifier;
|
||||
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.item.ItemBuildContext;
|
||||
import net.momirealms.craftengine.core.item.JukeboxPlayable;
|
||||
import net.momirealms.craftengine.core.item.data.JukeboxPlayable;
|
||||
|
||||
public class JukeboxSongModifier<I> implements ItemDataModifier<I> {
|
||||
private final JukeboxPlayable song;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.momirealms.craftengine.core.item.modifier;
|
||||
|
||||
import net.momirealms.craftengine.core.item.*;
|
||||
import net.momirealms.craftengine.core.item.data.Trim;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
import net.momirealms.sparrow.nbt.CompoundTag;
|
||||
import net.momirealms.sparrow.nbt.Tag;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.momirealms.craftengine.core.loot.function;
|
||||
|
||||
import net.momirealms.craftengine.core.item.Enchantment;
|
||||
import net.momirealms.craftengine.core.item.data.Enchantment;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.loot.LootConditions;
|
||||
import net.momirealms.craftengine.core.loot.LootContext;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.momirealms.craftengine.core.plugin.context.condition;
|
||||
|
||||
import net.momirealms.craftengine.core.item.Enchantment;
|
||||
import net.momirealms.craftengine.core.item.data.Enchantment;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.plugin.context.Condition;
|
||||
import net.momirealms.craftengine.core.plugin.context.Context;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.momirealms.craftengine.core.plugin.context.condition;
|
||||
|
||||
import net.momirealms.craftengine.core.item.Enchantment;
|
||||
import net.momirealms.craftengine.core.item.data.Enchantment;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.plugin.context.Condition;
|
||||
import net.momirealms.craftengine.core.plugin.context.Context;
|
||||
|
||||
@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Project settings
|
||||
# Rule: [major update].[feature update].[bug fix]
|
||||
project_version=0.0.58.5
|
||||
project_version=0.0.59
|
||||
config_version=40
|
||||
lang_version=21
|
||||
project_group=net.momirealms
|
||||
|
||||
Reference in New Issue
Block a user