[Change] Disabled EMI and Trinkets support for now
This commit is contained in:
parent
103518caf5
commit
21434e8b98
10 changed files with 323 additions and 326 deletions
|
@ -1,40 +1,40 @@
|
|||
package org.betterx.betterend.integration.emi;
|
||||
|
||||
import org.betterx.bclib.integration.emi.EMIAbstractAlloyingRecipe;
|
||||
import org.betterx.bclib.integration.emi.EMIPlugin;
|
||||
import org.betterx.betterend.BetterEnd;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.item.crafting.BlastingRecipe;
|
||||
import net.minecraft.world.item.crafting.RecipeManager;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
|
||||
import dev.emi.emi.api.EmiRegistry;
|
||||
|
||||
public class EMIBlastingRecipe extends EMIAbstractAlloyingRecipe<Container, BlastingRecipe> {
|
||||
public EMIBlastingRecipe(BlastingRecipe recipe) {
|
||||
super(recipe, new ResourceLocation(
|
||||
"emi",
|
||||
recipe.getId().getNamespace() + "/" + recipe.getId().getPath() + "/allloying"
|
||||
), 1, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSmeltTime() {
|
||||
return recipe.getCookingTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getExperience() {
|
||||
return recipe.getExperience();
|
||||
}
|
||||
|
||||
|
||||
static void addAllRecipes(EmiRegistry emiRegistry, RecipeManager manager) {
|
||||
EMIPlugin.addAllRecipes(
|
||||
emiRegistry, manager, BetterEnd.LOGGER,
|
||||
RecipeType.BLASTING, EMIBlastingRecipe::new
|
||||
);
|
||||
}
|
||||
}
|
||||
//import org.betterx.bclib.integration.emi.EMIAbstractAlloyingRecipe;
|
||||
//import org.betterx.bclib.integration.emi.EMIPlugin;
|
||||
//import org.betterx.betterend.BetterEnd;
|
||||
//
|
||||
//import net.minecraft.resources.ResourceLocation;
|
||||
//import net.minecraft.world.Container;
|
||||
//import net.minecraft.world.item.crafting.BlastingRecipe;
|
||||
//import net.minecraft.world.item.crafting.RecipeManager;
|
||||
//import net.minecraft.world.item.crafting.RecipeType;
|
||||
//
|
||||
//import dev.emi.emi.api.EmiRegistry;
|
||||
//
|
||||
//public class EMIBlastingRecipe extends EMIAbstractAlloyingRecipe<Container, BlastingRecipe> {
|
||||
// public EMIBlastingRecipe(BlastingRecipe recipe) {
|
||||
// super(recipe, new ResourceLocation(
|
||||
// "emi",
|
||||
// recipe.getId().getNamespace() + "/" + recipe.getId().getPath() + "/allloying"
|
||||
// ), 1, false);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected int getSmeltTime() {
|
||||
// return recipe.getCookingTime();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected float getExperience() {
|
||||
// return recipe.getExperience();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// static void addAllRecipes(EmiRegistry emiRegistry, RecipeManager manager) {
|
||||
// EMIPlugin.addAllRecipes(
|
||||
// emiRegistry, manager, BetterEnd.LOGGER,
|
||||
// RecipeType.BLASTING, EMIBlastingRecipe::new
|
||||
// );
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,132 +1,132 @@
|
|||
package org.betterx.betterend.integration.emi;
|
||||
|
||||
import org.betterx.betterend.BetterEnd;
|
||||
import org.betterx.betterend.recipe.builders.InfusionRecipe;
|
||||
import org.betterx.ui.ColorUtil;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
import net.minecraft.world.item.crafting.RecipeManager;
|
||||
|
||||
import dev.emi.emi.api.EmiRegistry;
|
||||
import dev.emi.emi.api.recipe.EmiRecipe;
|
||||
import dev.emi.emi.api.recipe.EmiRecipeCategory;
|
||||
import dev.emi.emi.api.render.EmiTexture;
|
||||
import dev.emi.emi.api.stack.EmiIngredient;
|
||||
import dev.emi.emi.api.stack.EmiStack;
|
||||
import dev.emi.emi.api.widget.SlotWidget;
|
||||
import dev.emi.emi.api.widget.WidgetHolder;
|
||||
|
||||
import java.util.List;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class EMIInfusionRecipe implements EmiRecipe {
|
||||
public final static EmiTexture BACKGROUND = new EmiTexture(
|
||||
BetterEnd.makeID("textures/gui/infusion.png"),
|
||||
0, 0,
|
||||
84, 84, 84, 84, 84, 84
|
||||
);
|
||||
|
||||
public final Component[] ORIENTATIONS = {
|
||||
Component.translatable("betterend.infusion.north").setStyle(Style.EMPTY.withColor(ColorUtil.GRAY)),
|
||||
Component.translatable("betterend.infusion.north_east").setStyle(Style.EMPTY.withColor(ColorUtil.GRAY)),
|
||||
Component.translatable("betterend.infusion.east").setStyle(Style.EMPTY.withColor(ColorUtil.GRAY)),
|
||||
Component.translatable("betterend.infusion.south_east").setStyle(Style.EMPTY.withColor(ColorUtil.GRAY)),
|
||||
Component.translatable("betterend.infusion.south").setStyle(Style.EMPTY.withColor(ColorUtil.GRAY)),
|
||||
Component.translatable("betterend.infusion.south_west").setStyle(Style.EMPTY.withColor(ColorUtil.GRAY)),
|
||||
Component.translatable("betterend.infusion.west").setStyle(Style.EMPTY.withColor(ColorUtil.GRAY)),
|
||||
Component.translatable("betterend.infusion.north_west").setStyle(Style.EMPTY.withColor(ColorUtil.GRAY)),
|
||||
};
|
||||
private final ResourceLocation id;
|
||||
private final List<EmiIngredient> input;
|
||||
private final List<EmiStack> output;
|
||||
|
||||
public EMIInfusionRecipe(InfusionRecipe recipe) {
|
||||
this.id = recipe.getId();
|
||||
this.input = recipe.getIngredients().stream().map(i -> EmiIngredient.of(i)).toList();
|
||||
this.output = List.of(EmiStack.of(recipe.getResultItem(Minecraft.getInstance().level.registryAccess())));
|
||||
}
|
||||
|
||||
static void addAllRecipes(EmiRegistry emiRegistry, RecipeManager manager) {
|
||||
org.betterx.bclib.integration.emi.EMIPlugin.addAllRecipes(
|
||||
emiRegistry, manager, BetterEnd.LOGGER,
|
||||
InfusionRecipe.TYPE, EMIInfusionRecipe::new
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EmiRecipeCategory getCategory() {
|
||||
return EMIPlugin.INFUSION_CATEGORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ResourceLocation getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EmiIngredient> getInputs() {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EmiStack> getOutputs() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayWidth() {
|
||||
return 4 + 10 + 84 + 68;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayHeight() {
|
||||
return 4 + 20 + 84;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWidgets(WidgetHolder widgets) {
|
||||
final int radius = 36;
|
||||
final int halfSize = 9;
|
||||
final int left = 10;
|
||||
final int top = 17;
|
||||
|
||||
final int cx = left + 84 / 2;
|
||||
final int cy = top + 84 / 2;
|
||||
|
||||
final int right = left + 84;
|
||||
final int bottom = top + 84;
|
||||
widgets.addTexture(BACKGROUND, left, top);
|
||||
// Add an arrow texture to indicate processing
|
||||
widgets.addTexture(EmiTexture.EMPTY_ARROW, right + 10, cy - 8);
|
||||
|
||||
// Adds an input slot on the left
|
||||
widgets.add(new SlotWidget(input.get(0), cx - halfSize, cy - halfSize));
|
||||
|
||||
FormattedCharSequence str = FormattedCharSequence.forward("N", Style.EMPTY);
|
||||
widgets.addText(str, cx - Minecraft.getInstance().font.width(str) / 2, 4, ColorUtil.WHITE, true);
|
||||
double a = Math.PI;
|
||||
for (int i = 1; i < input.size(); i++) {
|
||||
widgets.add(new SlotWidget(
|
||||
input.get(i),
|
||||
cx - halfSize + (int) (Math.sin(a) * radius),
|
||||
cy - halfSize + (int) (Math.cos(a) * radius)
|
||||
)).appendTooltip(ORIENTATIONS[i - 1]);
|
||||
a -= Math.PI / 4;
|
||||
}
|
||||
|
||||
// Adds an output slot on the right
|
||||
// Note that output slots need to call `recipeContext` to inform EMI about their recipe context
|
||||
// This includes being able to resolve recipe trees, favorite stacks with recipe context, and more
|
||||
widgets.addSlot(output.get(0), right + 40, cy - (halfSize + 4)).large(true).recipeContext(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsRecipeTree() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//import org.betterx.betterend.BetterEnd;
|
||||
//import org.betterx.betterend.recipe.builders.InfusionRecipe;
|
||||
//import org.betterx.ui.ColorUtil;
|
||||
//
|
||||
//import net.minecraft.client.Minecraft;
|
||||
//import net.minecraft.network.chat.Component;
|
||||
//import net.minecraft.network.chat.Style;
|
||||
//import net.minecraft.resources.ResourceLocation;
|
||||
//import net.minecraft.util.FormattedCharSequence;
|
||||
//import net.minecraft.world.item.crafting.RecipeManager;
|
||||
//
|
||||
//import dev.emi.emi.api.EmiRegistry;
|
||||
//import dev.emi.emi.api.recipe.EmiRecipe;
|
||||
//import dev.emi.emi.api.recipe.EmiRecipeCategory;
|
||||
//import dev.emi.emi.api.render.EmiTexture;
|
||||
//import dev.emi.emi.api.stack.EmiIngredient;
|
||||
//import dev.emi.emi.api.stack.EmiStack;
|
||||
//import dev.emi.emi.api.widget.SlotWidget;
|
||||
//import dev.emi.emi.api.widget.WidgetHolder;
|
||||
//
|
||||
//import java.util.List;
|
||||
//import org.jetbrains.annotations.Nullable;
|
||||
//
|
||||
//public class EMIInfusionRecipe implements EmiRecipe {
|
||||
// public final static EmiTexture BACKGROUND = new EmiTexture(
|
||||
// BetterEnd.makeID("textures/gui/infusion.png"),
|
||||
// 0, 0,
|
||||
// 84, 84, 84, 84, 84, 84
|
||||
// );
|
||||
//
|
||||
// public final Component[] ORIENTATIONS = {
|
||||
// Component.translatable("betterend.infusion.north").setStyle(Style.EMPTY.withColor(ColorUtil.GRAY)),
|
||||
// Component.translatable("betterend.infusion.north_east").setStyle(Style.EMPTY.withColor(ColorUtil.GRAY)),
|
||||
// Component.translatable("betterend.infusion.east").setStyle(Style.EMPTY.withColor(ColorUtil.GRAY)),
|
||||
// Component.translatable("betterend.infusion.south_east").setStyle(Style.EMPTY.withColor(ColorUtil.GRAY)),
|
||||
// Component.translatable("betterend.infusion.south").setStyle(Style.EMPTY.withColor(ColorUtil.GRAY)),
|
||||
// Component.translatable("betterend.infusion.south_west").setStyle(Style.EMPTY.withColor(ColorUtil.GRAY)),
|
||||
// Component.translatable("betterend.infusion.west").setStyle(Style.EMPTY.withColor(ColorUtil.GRAY)),
|
||||
// Component.translatable("betterend.infusion.north_west").setStyle(Style.EMPTY.withColor(ColorUtil.GRAY)),
|
||||
// };
|
||||
// private final ResourceLocation id;
|
||||
// private final List<EmiIngredient> input;
|
||||
// private final List<EmiStack> output;
|
||||
//
|
||||
// public EMIInfusionRecipe(InfusionRecipe recipe) {
|
||||
// this.id = recipe.getId();
|
||||
// this.input = recipe.getIngredients().stream().map(i -> EmiIngredient.of(i)).toList();
|
||||
// this.output = List.of(EmiStack.of(recipe.getResultItem(Minecraft.getInstance().level.registryAccess())));
|
||||
// }
|
||||
//
|
||||
// static void addAllRecipes(EmiRegistry emiRegistry, RecipeManager manager) {
|
||||
// org.betterx.bclib.integration.emi.EMIPlugin.addAllRecipes(
|
||||
// emiRegistry, manager, BetterEnd.LOGGER,
|
||||
// InfusionRecipe.TYPE, EMIInfusionRecipe::new
|
||||
// );
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public EmiRecipeCategory getCategory() {
|
||||
// return EMIPlugin.INFUSION_CATEGORY;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @Nullable ResourceLocation getId() {
|
||||
// return id;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<EmiIngredient> getInputs() {
|
||||
// return input;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<EmiStack> getOutputs() {
|
||||
// return output;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getDisplayWidth() {
|
||||
// return 4 + 10 + 84 + 68;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getDisplayHeight() {
|
||||
// return 4 + 20 + 84;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void addWidgets(WidgetHolder widgets) {
|
||||
// final int radius = 36;
|
||||
// final int halfSize = 9;
|
||||
// final int left = 10;
|
||||
// final int top = 17;
|
||||
//
|
||||
// final int cx = left + 84 / 2;
|
||||
// final int cy = top + 84 / 2;
|
||||
//
|
||||
// final int right = left + 84;
|
||||
// final int bottom = top + 84;
|
||||
// widgets.addTexture(BACKGROUND, left, top);
|
||||
// // Add an arrow texture to indicate processing
|
||||
// widgets.addTexture(EmiTexture.EMPTY_ARROW, right + 10, cy - 8);
|
||||
//
|
||||
// // Adds an input slot on the left
|
||||
// widgets.add(new SlotWidget(input.get(0), cx - halfSize, cy - halfSize));
|
||||
//
|
||||
// FormattedCharSequence str = FormattedCharSequence.forward("N", Style.EMPTY);
|
||||
// widgets.addText(str, cx - Minecraft.getInstance().font.width(str) / 2, 4, ColorUtil.WHITE, true);
|
||||
// double a = Math.PI;
|
||||
// for (int i = 1; i < input.size(); i++) {
|
||||
// widgets.add(new SlotWidget(
|
||||
// input.get(i),
|
||||
// cx - halfSize + (int) (Math.sin(a) * radius),
|
||||
// cy - halfSize + (int) (Math.cos(a) * radius)
|
||||
// )).appendTooltip(ORIENTATIONS[i - 1]);
|
||||
// a -= Math.PI / 4;
|
||||
// }
|
||||
//
|
||||
// // Adds an output slot on the right
|
||||
// // Note that output slots need to call `recipeContext` to inform EMI about their recipe context
|
||||
// // This includes being able to resolve recipe trees, favorite stacks with recipe context, and more
|
||||
// widgets.addSlot(output.get(0), right + 40, cy - (halfSize + 4)).large(true).recipeContext(this);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean supportsRecipeTree() {
|
||||
// return true;
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
package org.betterx.betterend.integration.emi;
|
||||
|
||||
import org.betterx.betterend.BetterEnd;
|
||||
import org.betterx.betterend.registry.EndBlocks;
|
||||
|
||||
import net.minecraft.world.item.crafting.RecipeManager;
|
||||
|
||||
import dev.emi.emi.api.EmiRegistry;
|
||||
import dev.emi.emi.api.recipe.EmiRecipeCategory;
|
||||
import dev.emi.emi.api.recipe.VanillaEmiRecipeCategories;
|
||||
import dev.emi.emi.api.stack.EmiStack;
|
||||
|
||||
public class EMIPlugin implements dev.emi.emi.api.EmiPlugin {
|
||||
public static final EmiStack INFUSION_WORKSTATION = EmiStack.of(EndBlocks.INFUSION_PEDESTAL);
|
||||
public static final EmiStack AZURE_JADESTONE_FURNACE_WORKSTATION = EmiStack.of(EndBlocks.AZURE_JADESTONE.furnace);
|
||||
public static final EmiStack SANDY_JADESTONE_FURNACE_WORKSTATION = EmiStack.of(EndBlocks.SANDY_JADESTONE.furnace);
|
||||
public static final EmiStack VIRID_JADESTONE_FURNACE_WORKSTATION = EmiStack.of(EndBlocks.VIRID_JADESTONE.furnace);
|
||||
|
||||
public static final EmiRecipeCategory INFUSION_CATEGORY = new EmiRecipeCategory(
|
||||
BetterEnd.makeID("infusion"),
|
||||
INFUSION_WORKSTATION,
|
||||
org.betterx.bclib.integration.emi.EMIPlugin.getSprite(0, 16)
|
||||
);
|
||||
|
||||
@Override
|
||||
public void register(EmiRegistry emiRegistry) {
|
||||
final RecipeManager manager = emiRegistry.getRecipeManager();
|
||||
emiRegistry.addCategory(INFUSION_CATEGORY);
|
||||
emiRegistry.addWorkstation(INFUSION_CATEGORY, INFUSION_WORKSTATION);
|
||||
|
||||
EMIInfusionRecipe.addAllRecipes(emiRegistry, manager);
|
||||
if (org.betterx.bclib.integration.emi.EMIPlugin.END_ALLOYING_CATEGORY != null) {
|
||||
EMIBlastingRecipe.addAllRecipes(emiRegistry, manager);
|
||||
}
|
||||
|
||||
emiRegistry.addWorkstation(VanillaEmiRecipeCategories.SMELTING, AZURE_JADESTONE_FURNACE_WORKSTATION);
|
||||
emiRegistry.addWorkstation(VanillaEmiRecipeCategories.SMELTING, SANDY_JADESTONE_FURNACE_WORKSTATION);
|
||||
emiRegistry.addWorkstation(VanillaEmiRecipeCategories.SMELTING, VIRID_JADESTONE_FURNACE_WORKSTATION);
|
||||
}
|
||||
}
|
||||
//import org.betterx.betterend.BetterEnd;
|
||||
//import org.betterx.betterend.registry.EndBlocks;
|
||||
//
|
||||
//import net.minecraft.world.item.crafting.RecipeManager;
|
||||
//
|
||||
//import dev.emi.emi.api.EmiRegistry;
|
||||
//import dev.emi.emi.api.recipe.EmiRecipeCategory;
|
||||
//import dev.emi.emi.api.recipe.VanillaEmiRecipeCategories;
|
||||
//import dev.emi.emi.api.stack.EmiStack;
|
||||
//
|
||||
//public class EMIPlugin implements dev.emi.emi.api.EmiPlugin {
|
||||
// public static final EmiStack INFUSION_WORKSTATION = EmiStack.of(EndBlocks.INFUSION_PEDESTAL);
|
||||
// public static final EmiStack AZURE_JADESTONE_FURNACE_WORKSTATION = EmiStack.of(EndBlocks.AZURE_JADESTONE.furnace);
|
||||
// public static final EmiStack SANDY_JADESTONE_FURNACE_WORKSTATION = EmiStack.of(EndBlocks.SANDY_JADESTONE.furnace);
|
||||
// public static final EmiStack VIRID_JADESTONE_FURNACE_WORKSTATION = EmiStack.of(EndBlocks.VIRID_JADESTONE.furnace);
|
||||
//
|
||||
// public static final EmiRecipeCategory INFUSION_CATEGORY = new EmiRecipeCategory(
|
||||
// BetterEnd.makeID("infusion"),
|
||||
// INFUSION_WORKSTATION,
|
||||
// org.betterx.bclib.integration.emi.EMIPlugin.getSprite(0, 16)
|
||||
// );
|
||||
//
|
||||
// @Override
|
||||
// public void register(EmiRegistry emiRegistry) {
|
||||
// final RecipeManager manager = emiRegistry.getRecipeManager();
|
||||
// emiRegistry.addCategory(INFUSION_CATEGORY);
|
||||
// emiRegistry.addWorkstation(INFUSION_CATEGORY, INFUSION_WORKSTATION);
|
||||
//
|
||||
// EMIInfusionRecipe.addAllRecipes(emiRegistry, manager);
|
||||
// if (org.betterx.bclib.integration.emi.EMIPlugin.END_ALLOYING_CATEGORY != null) {
|
||||
// EMIBlastingRecipe.addAllRecipes(emiRegistry, manager);
|
||||
// }
|
||||
//
|
||||
// emiRegistry.addWorkstation(VanillaEmiRecipeCategories.SMELTING, AZURE_JADESTONE_FURNACE_WORKSTATION);
|
||||
// emiRegistry.addWorkstation(VanillaEmiRecipeCategories.SMELTING, SANDY_JADESTONE_FURNACE_WORKSTATION);
|
||||
// emiRegistry.addWorkstation(VanillaEmiRecipeCategories.SMELTING, VIRID_JADESTONE_FURNACE_WORKSTATION);
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,88 +1,88 @@
|
|||
package org.betterx.betterend.integration.trinkets;
|
||||
|
||||
import org.betterx.bclib.items.elytra.BCLElytraItem;
|
||||
import org.betterx.bclib.items.elytra.BCLElytraUtils;
|
||||
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ElytraItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import net.fabricmc.fabric.api.entity.event.v1.EntityElytraEvents;
|
||||
import net.fabricmc.fabric.api.entity.event.v1.FabricElytraItem;
|
||||
|
||||
import dev.emi.trinkets.api.SlotReference;
|
||||
import dev.emi.trinkets.api.TrinketComponent;
|
||||
import dev.emi.trinkets.api.TrinketsApi;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class Elytra {
|
||||
private static boolean isElytra(ItemStack stack) {
|
||||
return stack.getItem() instanceof ElytraItem
|
||||
|| stack.getItem() instanceof FabricElytraItem;
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
BCLElytraUtils.slotProvider = (entity, slotGetter) -> {
|
||||
ItemStack itemStack = slotGetter.apply(EquipmentSlot.CHEST);
|
||||
if (isElytra(itemStack)) return itemStack;
|
||||
|
||||
Optional<TrinketComponent> oTrinketComponent = TrinketsApi.getTrinketComponent(entity);
|
||||
if (oTrinketComponent.isPresent()) {
|
||||
List<Tuple<SlotReference, ItemStack>> equipped =
|
||||
oTrinketComponent.get().getEquipped(Elytra::isElytra);
|
||||
|
||||
if (!equipped.isEmpty()) return equipped.get(0).getB();
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
BCLElytraUtils.onBreak = (entity, chestStack) -> {
|
||||
Optional<TrinketComponent> oTrinketComponent = TrinketsApi.getTrinketComponent(entity);
|
||||
if (oTrinketComponent.isPresent()) {
|
||||
List<Tuple<SlotReference, ItemStack>> equipped =
|
||||
oTrinketComponent.get().getEquipped(Elytra::isElytra);
|
||||
|
||||
for (Tuple<SlotReference, ItemStack> slot : equipped) {
|
||||
ItemStack slotStack = slot.getB();
|
||||
if (slotStack == chestStack) {
|
||||
TrinketsApi.onTrinketBroken(slotStack, slot.getA(), entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
EntityElytraEvents.CUSTOM.register(Elytra::useElytraTrinket);
|
||||
}
|
||||
|
||||
private static boolean useElytraTrinket(LivingEntity entity, boolean tickElytra) {
|
||||
Optional<TrinketComponent> oTrinketComponent = TrinketsApi.getTrinketComponent(entity);
|
||||
if (oTrinketComponent.isPresent()) {
|
||||
List<Tuple<SlotReference, ItemStack>> equipped =
|
||||
oTrinketComponent.get().getEquipped(Elytra::isElytra);
|
||||
|
||||
for (Tuple<SlotReference, ItemStack> slot : equipped) {
|
||||
ItemStack stack = slot.getB();
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (item instanceof ElytraItem) {
|
||||
if (ElytraItem.isFlyEnabled(stack)) {
|
||||
BCLElytraItem.vanillaElytraTick(entity, stack);
|
||||
return true;
|
||||
}
|
||||
} else if (item instanceof FabricElytraItem fabricElytraItem) {
|
||||
if (fabricElytraItem.useCustomElytra(entity, stack, tickElytra)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//import org.betterx.bclib.items.elytra.BCLElytraItem;
|
||||
//import org.betterx.bclib.items.elytra.BCLElytraUtils;
|
||||
//
|
||||
//import net.minecraft.util.Tuple;
|
||||
//import net.minecraft.world.entity.EquipmentSlot;
|
||||
//import net.minecraft.world.entity.LivingEntity;
|
||||
//import net.minecraft.world.item.ElytraItem;
|
||||
//import net.minecraft.world.item.Item;
|
||||
//import net.minecraft.world.item.ItemStack;
|
||||
//
|
||||
//import net.fabricmc.fabric.api.entity.event.v1.EntityElytraEvents;
|
||||
//import net.fabricmc.fabric.api.entity.event.v1.FabricElytraItem;
|
||||
//
|
||||
//import dev.emi.trinkets.api.SlotReference;
|
||||
//import dev.emi.trinkets.api.TrinketComponent;
|
||||
//import dev.emi.trinkets.api.TrinketsApi;
|
||||
//
|
||||
//import java.util.List;
|
||||
//import java.util.Optional;
|
||||
//
|
||||
//public class Elytra {
|
||||
// private static boolean isElytra(ItemStack stack) {
|
||||
// return stack.getItem() instanceof ElytraItem
|
||||
// || stack.getItem() instanceof FabricElytraItem;
|
||||
// }
|
||||
//
|
||||
// public static void register() {
|
||||
// BCLElytraUtils.slotProvider = (entity, slotGetter) -> {
|
||||
// ItemStack itemStack = slotGetter.apply(EquipmentSlot.CHEST);
|
||||
// if (isElytra(itemStack)) return itemStack;
|
||||
//
|
||||
// Optional<TrinketComponent> oTrinketComponent = TrinketsApi.getTrinketComponent(entity);
|
||||
// if (oTrinketComponent.isPresent()) {
|
||||
// List<Tuple<SlotReference, ItemStack>> equipped =
|
||||
// oTrinketComponent.get().getEquipped(Elytra::isElytra);
|
||||
//
|
||||
// if (!equipped.isEmpty()) return equipped.get(0).getB();
|
||||
// }
|
||||
// return null;
|
||||
// };
|
||||
//
|
||||
// BCLElytraUtils.onBreak = (entity, chestStack) -> {
|
||||
// Optional<TrinketComponent> oTrinketComponent = TrinketsApi.getTrinketComponent(entity);
|
||||
// if (oTrinketComponent.isPresent()) {
|
||||
// List<Tuple<SlotReference, ItemStack>> equipped =
|
||||
// oTrinketComponent.get().getEquipped(Elytra::isElytra);
|
||||
//
|
||||
// for (Tuple<SlotReference, ItemStack> slot : equipped) {
|
||||
// ItemStack slotStack = slot.getB();
|
||||
// if (slotStack == chestStack) {
|
||||
// TrinketsApi.onTrinketBroken(slotStack, slot.getA(), entity);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// EntityElytraEvents.CUSTOM.register(Elytra::useElytraTrinket);
|
||||
// }
|
||||
//
|
||||
// private static boolean useElytraTrinket(LivingEntity entity, boolean tickElytra) {
|
||||
// Optional<TrinketComponent> oTrinketComponent = TrinketsApi.getTrinketComponent(entity);
|
||||
// if (oTrinketComponent.isPresent()) {
|
||||
// List<Tuple<SlotReference, ItemStack>> equipped =
|
||||
// oTrinketComponent.get().getEquipped(Elytra::isElytra);
|
||||
//
|
||||
// for (Tuple<SlotReference, ItemStack> slot : equipped) {
|
||||
// ItemStack stack = slot.getB();
|
||||
// Item item = stack.getItem();
|
||||
//
|
||||
// if (item instanceof ElytraItem) {
|
||||
// if (ElytraItem.isFlyEnabled(stack)) {
|
||||
// BCLElytraItem.vanillaElytraTick(entity, stack);
|
||||
// return true;
|
||||
// }
|
||||
// } else if (item instanceof FabricElytraItem fabricElytraItem) {
|
||||
// if (fabricElytraItem.useCustomElytra(entity, stack, tickElytra)) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
package org.betterx.betterend.integration.trinkets;
|
||||
|
||||
import net.minecraft.world.item.ElytraItem;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRenderEvents;
|
||||
import net.fabricmc.fabric.api.entity.event.v1.FabricElytraItem;
|
||||
|
||||
import dev.emi.trinkets.api.TrinketsApi;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class ElytraClient {
|
||||
public static void register() {
|
||||
LivingEntityFeatureRenderEvents.ALLOW_CAPE_RENDER.register((player) -> TrinketsApi
|
||||
.getTrinketComponent(player)
|
||||
.map(trinketComponent -> trinketComponent.getEquipped(
|
||||
stack -> stack.getItem() instanceof ElytraItem ||
|
||||
stack.getItem() instanceof FabricElytraItem
|
||||
).size() == 0).orElse(true));
|
||||
}
|
||||
}
|
||||
//package org.betterx.betterend.integration.trinkets;
|
||||
//
|
||||
//import net.minecraft.world.item.ElytraItem;
|
||||
//
|
||||
//import net.fabricmc.api.EnvType;
|
||||
//import net.fabricmc.api.Environment;
|
||||
//import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRenderEvents;
|
||||
//import net.fabricmc.fabric.api.entity.event.v1.FabricElytraItem;
|
||||
//
|
||||
//import dev.emi.trinkets.api.TrinketsApi;
|
||||
//
|
||||
//@Environment(EnvType.CLIENT)
|
||||
//public class ElytraClient {
|
||||
// public static void register() {
|
||||
// LivingEntityFeatureRenderEvents.ALLOW_CAPE_RENDER.register((player) -> TrinketsApi
|
||||
// .getTrinketComponent(player)
|
||||
// .map(trinketComponent -> trinketComponent.getEquipped(
|
||||
// stack -> stack.getItem() instanceof ElytraItem ||
|
||||
// stack.getItem() instanceof FabricElytraItem
|
||||
// ).size() == 0).orElse(true));
|
||||
// }
|
||||
//}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue