Moving to source sets
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration;
|
||||
|
||||
public interface IIntegrationModule {
|
||||
|
||||
default boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
class Stub implements IIntegrationModule {
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2020, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration;
|
||||
|
||||
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
|
||||
|
||||
import appeng.integration.modules.theoneprobe.TOP;
|
||||
|
||||
public class Integrations {
|
||||
|
||||
public static void enqueueIMC(final InterModEnqueueEvent event) {
|
||||
TOP.enqueueIMC(event);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
|
||||
import team.chisel.ctm.api.IFacade;
|
||||
|
||||
/**
|
||||
* Neat abstraction class for All the IFacade interfaces.
|
||||
*
|
||||
* @author covers1624
|
||||
*/
|
||||
public interface IAEFacade extends IFacade {
|
||||
|
||||
BlockState getFacadeState(BlockView world, BlockPos pos, @Nullable Direction side);
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
default BlockState getFacade(@Nonnull BlockView world, @Nonnull BlockPos pos, @Nullable Direction side) {
|
||||
return getFacadeState(world, pos, side);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
default BlockState getFacade(@Nonnull BlockView world, @Nonnull BlockPos pos, @Nullable Direction side,
|
||||
@Nonnull BlockPos connection) {
|
||||
return getFacadeState(world, pos, side);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
/**
|
||||
* Abstracts access to the JEI API functionality.
|
||||
*/
|
||||
public interface IJEI extends IIntegrationModule {
|
||||
|
||||
default String getSearchText() {
|
||||
return "";
|
||||
}
|
||||
|
||||
default void setSearchText(String searchText) {
|
||||
}
|
||||
|
||||
class Stub extends IIntegrationModule.Stub implements IJEI {
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
public final class JEIFacade {
|
||||
|
||||
private JEIFacade() {
|
||||
}
|
||||
|
||||
private static IJEI instance = new IJEI.Stub();
|
||||
|
||||
public static IJEI instance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void setInstance(IJEI jei) {
|
||||
instance = Preconditions.checkNotNull(jei);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraftforge.fml.client.gui.HoverChecker;
|
||||
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import mezz.jei.api.gui.drawable.IDrawableAnimated;
|
||||
import mezz.jei.api.gui.drawable.IDrawableStatic;
|
||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.api.implementations.items.IStorageComponent;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.misc.CondenserBlockEntity;
|
||||
|
||||
class CondenserCategory implements IRecipeCategory<CondenserOutput> {
|
||||
|
||||
public static final Identifier UID = new Identifier(AppEng.MOD_ID, "condenser");
|
||||
|
||||
private final String localizedName;
|
||||
|
||||
private final IDrawable background;
|
||||
|
||||
private final IDrawable iconTrash;
|
||||
|
||||
private final IDrawableAnimated progress;
|
||||
|
||||
private final IDrawable iconButton;
|
||||
|
||||
private final IDrawable icon;
|
||||
|
||||
private final HoverChecker buttonHoverChecker;
|
||||
|
||||
private final Map<CondenserOutput, IDrawable> buttonIcons;
|
||||
|
||||
public CondenserCategory(IGuiHelper guiHelper) {
|
||||
this.localizedName = I18n.format("gui.appliedenergistics2.Condenser");
|
||||
this.icon = guiHelper.createDrawableIngredient(Api.INSTANCE.definitions().blocks().condenser().stack(1));
|
||||
|
||||
Identifier location = new Identifier(AppEng.MOD_ID, "textures/guis/condenser.png");
|
||||
this.background = guiHelper.createDrawable(location, 50, 25, 94, 48);
|
||||
|
||||
Identifier statesLocation = new Identifier(AppEng.MOD_ID, "textures/guis/states.png");
|
||||
this.iconTrash = guiHelper.drawableBuilder(statesLocation, 241, 81, 14, 14).addPadding(28, 0, 2, 0).build();
|
||||
this.iconButton = guiHelper.drawableBuilder(statesLocation, 240, 240, 16, 16).addPadding(28, 0, 78, 0).build();
|
||||
|
||||
IDrawableStatic progressDrawable = guiHelper.drawableBuilder(location, 178, 25, 6, 18).addPadding(0, 0, 70, 0)
|
||||
.build();
|
||||
this.progress = guiHelper.createAnimatedDrawable(progressDrawable, 40, IDrawableAnimated.StartDirection.BOTTOM,
|
||||
false);
|
||||
|
||||
this.buttonIcons = new EnumMap<>(CondenserOutput.class);
|
||||
|
||||
this.buttonIcons.put(CondenserOutput.MATTER_BALLS,
|
||||
guiHelper.drawableBuilder(statesLocation, 16, 112, 14, 14).addPadding(28, 0, 78, 0).build());
|
||||
this.buttonIcons.put(CondenserOutput.SINGULARITY,
|
||||
guiHelper.drawableBuilder(statesLocation, 32, 112, 14, 14).addPadding(28, 0, 78, 0).build());
|
||||
this.buttonHoverChecker = new HoverChecker(28, 28 + 16, 78, 78 + 16, 0);
|
||||
}
|
||||
|
||||
private ItemStack getOutput(CondenserOutput recipe) {
|
||||
switch (recipe) {
|
||||
case MATTER_BALLS:
|
||||
return Api.INSTANCE.definitions().materials().matterBall().stack(1);
|
||||
case SINGULARITY:
|
||||
return Api.INSTANCE.definitions().materials().singularity().stack(1);
|
||||
default:
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getUid() {
|
||||
return CondenserCategory.UID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends CondenserOutput> getRecipeClass() {
|
||||
return CondenserOutput.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return this.localizedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(CondenserOutput recipe, IIngredients ingredients) {
|
||||
ingredients.setOutput(VanillaTypes.ITEM, getOutput(recipe));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(CondenserOutput recipe, double mouseX, double mouseY) {
|
||||
this.progress.draw();
|
||||
this.iconTrash.draw();
|
||||
this.iconButton.draw();
|
||||
|
||||
IDrawable buttonIcon = this.buttonIcons.get(recipe);
|
||||
if (buttonIcon != null) {
|
||||
buttonIcon.draw();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, CondenserOutput output, IIngredients ingredients) {
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
itemStacks.init(0, false, 54, 26);
|
||||
|
||||
// Get all storage cells and cycle them through a fake input slot
|
||||
itemStacks.init(1, true, 50, 0);
|
||||
itemStacks.set(1, this.getViableStorageComponents(output));
|
||||
|
||||
// This only sets the output
|
||||
itemStacks.set(ingredients);
|
||||
}
|
||||
|
||||
private List<ItemStack> getViableStorageComponents(CondenserOutput condenserOutput) {
|
||||
IMaterials materials = AEApi.instance().definitions().materials();
|
||||
List<ItemStack> viableComponents = new ArrayList<>();
|
||||
materials.cell1kPart().maybeStack(1)
|
||||
.ifPresent(itemStack -> this.addViableComponent(condenserOutput, viableComponents, itemStack));
|
||||
materials.cell4kPart().maybeStack(1)
|
||||
.ifPresent(itemStack -> this.addViableComponent(condenserOutput, viableComponents, itemStack));
|
||||
materials.cell16kPart().maybeStack(1)
|
||||
.ifPresent(itemStack -> this.addViableComponent(condenserOutput, viableComponents, itemStack));
|
||||
materials.cell64kPart().maybeStack(1)
|
||||
.ifPresent(itemStack -> this.addViableComponent(condenserOutput, viableComponents, itemStack));
|
||||
return viableComponents;
|
||||
}
|
||||
|
||||
private void addViableComponent(CondenserOutput condenserOutput, List<ItemStack> viableComponents,
|
||||
ItemStack itemStack) {
|
||||
IStorageComponent comp = (IStorageComponent) itemStack.getItem();
|
||||
int storage = comp.getBytes(itemStack) * CondenserBlockEntity.BYTE_MULTIPLIER;
|
||||
if (storage >= condenserOutput.requiredPower) {
|
||||
viableComponents.add(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTooltipStrings(CondenserOutput output, double mouseX, double mouseY) {
|
||||
|
||||
if (this.buttonHoverChecker.checkHover((int) mouseX, (int) mouseY)) {
|
||||
String key;
|
||||
|
||||
switch (output) {
|
||||
case MATTER_BALLS:
|
||||
key = "gui.tooltips.appliedenergistics2.MatterBalls";
|
||||
break;
|
||||
case SINGULARITY:
|
||||
key = "gui.tooltips.appliedenergistics2.Singularity";
|
||||
break;
|
||||
default:
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return Splitter.on("\\n").splitToList(I18n.format(key, output.requiredPower));
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.ShapedRecipe;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
|
||||
import mezz.jei.api.constants.VanillaRecipeCategoryUid;
|
||||
import mezz.jei.api.recipe.IFocus;
|
||||
import mezz.jei.api.recipe.advanced.IRecipeManagerPlugin;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import appeng.items.parts.FacadeItem;
|
||||
|
||||
/**
|
||||
* This plugin will dynamically add facade recipes for any item that can be
|
||||
* turned into a facade.
|
||||
*/
|
||||
class FacadeRegistryPlugin implements IRecipeManagerPlugin {
|
||||
|
||||
private final FacadeItem itemFacade;
|
||||
|
||||
private final ItemStack cableAnchor;
|
||||
|
||||
FacadeRegistryPlugin(FacadeItem itemFacade, ItemStack cableAnchor) {
|
||||
this.itemFacade = itemFacade;
|
||||
this.cableAnchor = cableAnchor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> List<Identifier> getRecipeCategoryUids(IFocus<V> focus) {
|
||||
if (focus.getMode() == IFocus.Mode.OUTPUT && focus.getValue() instanceof ItemStack) {
|
||||
// Looking up how a certain facade is crafted
|
||||
ItemStack itemStack = (ItemStack) focus.getValue();
|
||||
if (itemStack.getItem() instanceof FacadeItem) {
|
||||
return Collections.singletonList(VanillaRecipeCategoryUid.CRAFTING);
|
||||
}
|
||||
} else if (focus.getMode() == IFocus.Mode.INPUT && focus.getValue() instanceof ItemStack) {
|
||||
// Looking up if a certain block can be used to make a facade
|
||||
ItemStack itemStack = (ItemStack) focus.getValue();
|
||||
|
||||
if (!this.itemFacade.createFacadeForItem(itemStack, true).isEmpty()) {
|
||||
return Collections.singletonList(VanillaRecipeCategoryUid.CRAFTING);
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T, V> List<T> getRecipes(IRecipeCategory<T> recipeCategory, IFocus<V> focus) {
|
||||
if (!VanillaRecipeCategoryUid.CRAFTING.equals(recipeCategory.getUid())) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
if (focus.getMode() == IFocus.Mode.OUTPUT && focus.getValue() instanceof ItemStack) {
|
||||
// Looking up how a certain facade is crafted
|
||||
ItemStack itemStack = (ItemStack) focus.getValue();
|
||||
if (itemStack.getItem() instanceof FacadeItem) {
|
||||
FacadeItem facadeItem = (FacadeItem) itemStack.getItem();
|
||||
ItemStack textureItem = facadeItem.getTextureItem(itemStack);
|
||||
return Collections.singletonList((T) make(textureItem, this.cableAnchor, itemStack));
|
||||
}
|
||||
} else if (focus.getMode() == IFocus.Mode.INPUT && focus.getValue() instanceof ItemStack) {
|
||||
// Looking up if a certain block can be used to make a facade
|
||||
|
||||
ItemStack itemStack = (ItemStack) focus.getValue();
|
||||
ItemStack facade = this.itemFacade.createFacadeForItem(itemStack, false);
|
||||
|
||||
if (!facade.isEmpty()) {
|
||||
return Collections.singletonList((T) make(itemStack, this.cableAnchor, facade));
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private ShapedRecipe make(ItemStack textureItem, ItemStack cableAnchor, ItemStack result) {
|
||||
// This id should only be used within JEI and not really matter
|
||||
Identifier id = new Identifier(AppEng.MOD_ID,
|
||||
"facade/" + textureItem.getItem().getRegistryName().toString().replace(':', '/'));
|
||||
|
||||
DefaultedList<Ingredient> ingredients = DefaultedList.withSize(9, Ingredient.EMPTY);
|
||||
ingredients.set(1, Ingredient.fromStacks(cableAnchor));
|
||||
ingredients.set(3, Ingredient.fromStacks(cableAnchor));
|
||||
ingredients.set(5, Ingredient.fromStacks(cableAnchor));
|
||||
ingredients.set(7, Ingredient.fromStacks(cableAnchor));
|
||||
ingredients.set(4, Ingredient.fromStacks(textureItem));
|
||||
|
||||
return new ShapedRecipe(id, "", 3, 3, ingredients, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> getRecipes(IRecipeCategory<T> recipeCategory) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.recipes.handlers.GrinderOptionalResult;
|
||||
import appeng.recipes.handlers.GrinderRecipe;
|
||||
|
||||
class GrinderRecipeCategory implements IRecipeCategory<GrinderRecipe> {
|
||||
|
||||
public static final Identifier UID = new Identifier(AppEng.MOD_ID, "grinder");
|
||||
|
||||
private final String localizedName;
|
||||
|
||||
private final IDrawable background;
|
||||
|
||||
private final IDrawable icon;
|
||||
|
||||
public GrinderRecipeCategory(IGuiHelper guiHelper) {
|
||||
this.localizedName = I18n.format("block.appliedenergistics2.grindstone");
|
||||
|
||||
Identifier location = new Identifier(AppEng.MOD_ID, "textures/guis/grinder.png");
|
||||
this.background = guiHelper.createDrawable(location, 11, 16, 154, 70);
|
||||
|
||||
this.icon = guiHelper.createDrawableIngredient(Api.INSTANCE.definitions().blocks().grindstone().stack(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getUid() {
|
||||
return GrinderRecipeCategory.UID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return this.localizedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, GrinderRecipe recipe, IIngredients ingredients) {
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
itemStacks.init(0, true, 0, 0);
|
||||
itemStacks.init(1, false, 100, 46);
|
||||
itemStacks.init(2, false, 118, 46);
|
||||
itemStacks.init(3, false, 136, 46);
|
||||
|
||||
itemStacks.set(ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GrinderRecipe> getRecipeClass() {
|
||||
return GrinderRecipe.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(GrinderRecipe recipe, IIngredients ingredients) {
|
||||
ingredients.setInputIngredients(Collections.singletonList(recipe.getIngredient()));
|
||||
List<ItemStack> outputs = new ArrayList<>(3);
|
||||
outputs.add(recipe.getOutput());
|
||||
for (GrinderOptionalResult optionalResult : recipe.getOptionalResults()) {
|
||||
outputs.add(optionalResult.getResult());
|
||||
}
|
||||
ingredients.setOutputs(VanillaTypes.ITEM, outputs);
|
||||
}
|
||||
|
||||
// FIXME USE SPECIAL INGREDIENT TYPE
|
||||
// FIXME @Override
|
||||
// FIXME public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY )
|
||||
// FIXME {
|
||||
// FIXME
|
||||
// FIXME FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
// FIXME
|
||||
// FIXME int x = 118;
|
||||
// FIXME
|
||||
// FIXME final float scale = 0.85f;
|
||||
// FIXME final float invScale = 1 / scale;
|
||||
// FIXME GlStateManager.scale( scale, scale, 1 );
|
||||
// FIXME
|
||||
// FIXME if( this.recipe.getOptionalOutput() != null )
|
||||
// FIXME {
|
||||
// FIXME String text = String.format( "%d%%", (int) ( this.recipe.getOptionalChance() * 100 ) );
|
||||
// FIXME float width = fr.getStringWidth( text ) * scale;
|
||||
// FIXME int xScaled = Math.round( ( x + ( 18 - width ) / 2 ) * invScale );
|
||||
// FIXME fr.drawString( text, xScaled, (int) ( 65 * invScale ), Color.gray.getRGB() );
|
||||
// FIXME x += 18;
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME if( this.recipe.getSecondOptionalOutput() != null )
|
||||
// FIXME {
|
||||
// FIXME String text = String.format( "%d%%", (int) ( this.recipe.getSecondOptionalChance() * 100 ) );
|
||||
// FIXME float width = fr.getStringWidth( text ) * scale;
|
||||
// FIXME int xScaled = Math.round( ( x + ( 18 - width ) / 2 ) * invScale );
|
||||
// FIXME fr.drawString( text, xScaled, (int) ( 65 * invScale ), Color.gray.getRGB() );
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME GlStateManager.scale( invScale, invScale, 1 );
|
||||
// FIXME }
|
||||
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import mezz.jei.api.gui.drawable.IDrawableAnimated;
|
||||
import mezz.jei.api.gui.drawable.IDrawableStatic;
|
||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.recipes.handlers.InscriberRecipe;
|
||||
|
||||
class InscriberRecipeCategory implements IRecipeCategory<InscriberRecipe> {
|
||||
|
||||
private static final int SLOT_INPUT_TOP = 0;
|
||||
private static final int SLOT_INPUT_MIDDLE = 1;
|
||||
private static final int SLOT_INPUT_BOTTOM = 2;
|
||||
private static final int SLOT_OUTPUT = 3;
|
||||
|
||||
static final Identifier UID = new Identifier(AppEng.MOD_ID, "appliedenergistics2.inscriber");
|
||||
|
||||
private final IDrawable background;
|
||||
|
||||
private final String localizedName;
|
||||
|
||||
private final IDrawableAnimated progress;
|
||||
|
||||
private final IDrawable icon;
|
||||
|
||||
public InscriberRecipeCategory(IGuiHelper guiHelper) {
|
||||
Identifier location = new Identifier(AppEng.MOD_ID, "textures/guis/inscriber.png");
|
||||
this.background = guiHelper.createDrawable(location, 44, 15, 97, 64);
|
||||
this.localizedName = I18n.format("block.appliedenergistics2.inscriber");
|
||||
|
||||
IDrawableStatic progressDrawable = guiHelper.drawableBuilder(location, 135, 177, 6, 18).addPadding(24, 0, 91, 0)
|
||||
.build();
|
||||
this.progress = guiHelper.createAnimatedDrawable(progressDrawable, 40, IDrawableAnimated.StartDirection.BOTTOM,
|
||||
false);
|
||||
|
||||
this.icon = guiHelper.createDrawableIngredient(Api.INSTANCE.definitions().blocks().inscriber().stack(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getUid() {
|
||||
return UID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return this.localizedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, InscriberRecipe recipeWrapper, IIngredients ingredients) {
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
itemStacks.init(SLOT_INPUT_TOP, true, 0, 0);
|
||||
itemStacks.init(SLOT_INPUT_MIDDLE, true, 18, 23);
|
||||
itemStacks.init(SLOT_INPUT_BOTTOM, true, 0, 46);
|
||||
itemStacks.init(SLOT_OUTPUT, false, 68, 24);
|
||||
|
||||
itemStacks.set(ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends InscriberRecipe> getRecipeClass() {
|
||||
return InscriberRecipe.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getIcon() {
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(InscriberRecipe recipe, IIngredients ingredients) {
|
||||
ingredients.setInputIngredients(recipe.getIngredients());
|
||||
ingredients.setOutput(VanillaTypes.ITEM, recipe.getOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(InscriberRecipe recipe, double mouseX, double mouseY) {
|
||||
this.progress.draw();
|
||||
}
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.RecipeManager;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.JeiPlugin;
|
||||
import mezz.jei.api.constants.VanillaRecipeCategoryUid;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.registration.*;
|
||||
import mezz.jei.api.runtime.IJeiRuntime;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.container.implementations.CraftingTermContainer;
|
||||
import appeng.container.implementations.PatternTermContainer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.integration.abstraction.JEIFacade;
|
||||
import appeng.items.parts.FacadeItem;
|
||||
import appeng.recipes.handlers.GrinderRecipe;
|
||||
import appeng.recipes.handlers.InscriberRecipe;
|
||||
|
||||
@JeiPlugin
|
||||
public class JEIPlugin implements IModPlugin {
|
||||
private static final Identifier ID = new Identifier(AppEng.MOD_ID, "core");
|
||||
|
||||
@Override
|
||||
public Identifier getPluginUid() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerItemSubtypes(ISubtypeRegistration subtypeRegistry) {
|
||||
final Optional<Item> maybeFacade = AEApi.instance().definitions().items().facade().maybeItem();
|
||||
maybeFacade.ifPresent(subtypeRegistry::useNbtForSubtypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCategories(IRecipeCategoryRegistration registry) {
|
||||
registry.addRecipeCategories(new GrinderRecipeCategory(registry.getJeiHelpers().getGuiHelper()),
|
||||
new CondenserCategory(registry.getJeiHelpers().getGuiHelper()),
|
||||
new InscriberRecipeCategory(registry.getJeiHelpers().getGuiHelper()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipeTransferHandlers(IRecipeTransferRegistration registration) {
|
||||
// Allow recipe transfer from JEI to crafting and pattern terminal
|
||||
registration.addRecipeTransferHandler(new RecipeTransferHandler<>(CraftingTermContainer.class),
|
||||
VanillaRecipeCategoryUid.CRAFTING);
|
||||
registration.addRecipeTransferHandler(new RecipeTransferHandler<>(PatternTermContainer.class),
|
||||
VanillaRecipeCategoryUid.CRAFTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes(IRecipeRegistration registration) {
|
||||
|
||||
IDefinitions definitions = AEApi.instance().definitions();
|
||||
|
||||
RecipeManager recipeManager = MinecraftClient.getInstance().world.getRecipeManager();
|
||||
registration.addRecipes(recipeManager.getRecipes(GrinderRecipe.TYPE).values(), GrinderRecipeCategory.UID);
|
||||
registration.addRecipes(recipeManager.getRecipes(InscriberRecipe.TYPE).values(), InscriberRecipeCategory.UID);
|
||||
registration.addRecipes(ImmutableList.of(CondenserOutput.MATTER_BALLS, CondenserOutput.SINGULARITY),
|
||||
CondenserCategory.UID);
|
||||
|
||||
registerDescriptions(definitions, registration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
|
||||
IDefinitions definitions = AEApi.instance().definitions();
|
||||
|
||||
ItemStack grindstone = definitions.blocks().grindstone().stack(1);
|
||||
registration.addRecipeCatalyst(grindstone, GrinderRecipeCategory.UID);
|
||||
|
||||
ItemStack condenser = definitions.blocks().condenser().stack(1);
|
||||
registration.addRecipeCatalyst(condenser, CondenserCategory.UID);
|
||||
|
||||
ItemStack inscriber = definitions.blocks().inscriber().stack(1);
|
||||
registration.addRecipeCatalyst(inscriber, InscriberRecipeCategory.UID);
|
||||
}
|
||||
|
||||
private void registerDescriptions(IDefinitions definitions, IRecipeRegistration registry) {
|
||||
IMaterials materials = definitions.materials();
|
||||
|
||||
final String[] message;
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.CERTUS_QUARTZ_WORLD_GEN)) {
|
||||
message = new String[] { GuiText.ChargedQuartz.getTranslationKey(), "",
|
||||
GuiText.ChargedQuartzFind.getTranslationKey() };
|
||||
} else {
|
||||
message = new String[] { GuiText.ChargedQuartzFind.getTranslationKey() };
|
||||
}
|
||||
this.addDescription(registry, materials.certusQuartzCrystalCharged(), message);
|
||||
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.METEORITE_WORLD_GEN)) {
|
||||
this.addDescription(registry, materials.logicProcessorPress(),
|
||||
GuiText.inWorldCraftingPresses.getTranslationKey());
|
||||
this.addDescription(registry, materials.calcProcessorPress(),
|
||||
GuiText.inWorldCraftingPresses.getTranslationKey());
|
||||
this.addDescription(registry, materials.engProcessorPress(),
|
||||
GuiText.inWorldCraftingPresses.getTranslationKey());
|
||||
}
|
||||
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_FLUIX)) {
|
||||
this.addDescription(registry, materials.fluixCrystal(), GuiText.inWorldFluix.getTranslationKey());
|
||||
}
|
||||
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_SINGULARITY)) {
|
||||
this.addDescription(registry, materials.qESingularity(), GuiText.inWorldSingularity.getTranslationKey());
|
||||
}
|
||||
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_PURIFICATION)) {
|
||||
this.addDescription(registry, materials.purifiedCertusQuartzCrystal(),
|
||||
GuiText.inWorldPurificationCertus.getTranslationKey());
|
||||
this.addDescription(registry, materials.purifiedNetherQuartzCrystal(),
|
||||
GuiText.inWorldPurificationNether.getTranslationKey());
|
||||
this.addDescription(registry, materials.purifiedFluixCrystal(),
|
||||
GuiText.inWorldPurificationFluix.getTranslationKey());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addDescription(IRecipeRegistration registry, IItemDefinition itemDefinition, String... message) {
|
||||
registry.addIngredientInfo(itemDefinition.stack(1), VanillaTypes.ITEM, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAdvanced(IAdvancedRegistration registration) {
|
||||
|
||||
IDefinitions definitions = AEApi.instance().definitions();
|
||||
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.ENABLE_FACADE_CRAFTING)) {
|
||||
FacadeItem itemFacade = (FacadeItem) definitions.items().facade().item();
|
||||
ItemStack cableAnchor = definitions.parts().cableAnchor().stack(1);
|
||||
registration.addRecipeManagerPlugin(new FacadeRegistryPlugin(itemFacade, cableAnchor));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
|
||||
JEIFacade.setInstance(new JeiRuntimeAdapter(jeiRuntime));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import mezz.jei.api.runtime.IJeiRuntime;
|
||||
|
||||
import appeng.integration.abstraction.IJEI;
|
||||
|
||||
class JeiRuntimeAdapter implements IJEI {
|
||||
|
||||
private final IJeiRuntime runtime;
|
||||
|
||||
JeiRuntimeAdapter(IJeiRuntime jeiRuntime) {
|
||||
this.runtime = jeiRuntime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSearchText() {
|
||||
return Strings.nullToEmpty(this.runtime.getIngredientFilter().getFilterText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSearchText(String searchText) {
|
||||
this.runtime.getIngredientFilter().setFilterText(Strings.nullToEmpty(searchText));
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.ingredient.IGuiIngredient;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
||||
|
||||
import appeng.container.slot.CraftingMatrixSlot;
|
||||
import appeng.container.slot.FakeCraftingMatrixSlot;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.JEIRecipePacket;
|
||||
import appeng.util.Platform;
|
||||
|
||||
class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandler<T> {
|
||||
|
||||
private final Class<T> containerClass;
|
||||
|
||||
RecipeTransferHandler(Class<T> containerClass) {
|
||||
this.containerClass = containerClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<T> getContainerClass() {
|
||||
return this.containerClass;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IRecipeTransferError transferRecipe(T container, IRecipeLayout recipeLayout, PlayerEntity player,
|
||||
boolean maxTransfer, boolean doTransfer) {
|
||||
if (!doTransfer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<Integer, ? extends IGuiIngredient<ItemStack>> ingredients = recipeLayout.getItemStacks()
|
||||
.getGuiIngredients();
|
||||
|
||||
final CompoundTag recipe = new CompoundTag();
|
||||
|
||||
int slotIndex = 0;
|
||||
for (Map.Entry<Integer, ? extends IGuiIngredient<ItemStack>> ingredientEntry : ingredients.entrySet()) {
|
||||
IGuiIngredient<ItemStack> ingredient = ingredientEntry.getValue();
|
||||
if (!ingredient.isInput()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (final Slot slot : container.inventorySlots) {
|
||||
if (slot instanceof CraftingMatrixSlot || slot instanceof FakeCraftingMatrixSlot) {
|
||||
if (slot.getSlotIndex() == slotIndex) {
|
||||
final ListTag tags = new ListTag();
|
||||
final List<ItemStack> list = new ArrayList<>();
|
||||
final ItemStack displayed = ingredient.getDisplayedIngredient();
|
||||
|
||||
// prefer currently displayed item
|
||||
if (displayed != null && !displayed.isEmpty()) {
|
||||
list.add(displayed);
|
||||
}
|
||||
|
||||
// prefer pure crystals.
|
||||
for (ItemStack stack : ingredient.getAllIngredients()) {
|
||||
if (Platform.isRecipePrioritized(stack)) {
|
||||
list.add(0, stack);
|
||||
} else {
|
||||
list.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
for (final ItemStack is : list) {
|
||||
final CompoundTag tag = new CompoundTag();
|
||||
is.toTag(tag);
|
||||
tags.add(tag);
|
||||
}
|
||||
|
||||
recipe.put("#" + slot.getSlotIndex(), tags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
slotIndex++;
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer(new JEIRecipePacket(recipe));
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.theoneprobe;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.IProbeInfoProvider;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.integration.modules.theoneprobe.part.ChannelInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.part.IPartProbInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.part.P2PStateInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.part.PartAccessor;
|
||||
import appeng.integration.modules.theoneprobe.part.PowerStateInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.part.StorageMonitorInfoProvider;
|
||||
|
||||
public final class PartInfoProvider implements IProbeInfoProvider {
|
||||
private final List<IPartProbInfoProvider> providers;
|
||||
|
||||
private final PartAccessor accessor = new PartAccessor();
|
||||
|
||||
public PartInfoProvider() {
|
||||
final IPartProbInfoProvider channel = new ChannelInfoProvider();
|
||||
final IPartProbInfoProvider power = new PowerStateInfoProvider();
|
||||
final IPartProbInfoProvider storageMonitor = new StorageMonitorInfoProvider();
|
||||
final IPartProbInfoProvider p2p = new P2PStateInfoProvider();
|
||||
|
||||
this.providers = Lists.newArrayList(channel, power, p2p, storageMonitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return AppEng.MOD_ID + ":PartInfoProvider";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world,
|
||||
BlockState blockState, IProbeHitData data) {
|
||||
final BlockEntity te = world.getBlockEntity(data.getPos());
|
||||
final Optional<IPart> maybePart = this.accessor.getMaybePart(te, data);
|
||||
|
||||
if (maybePart.isPresent()) {
|
||||
final IPart part = maybePart.get();
|
||||
|
||||
for (final IPartProbInfoProvider provider : this.providers) {
|
||||
provider.addProbeInfo(part, mode, probeInfo, player, world, blockState, data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2020, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.theoneprobe;
|
||||
|
||||
import net.minecraftforge.fml.InterModComms;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
|
||||
|
||||
public class TOP {
|
||||
public static void enqueueIMC(final InterModEnqueueEvent event) {
|
||||
if (ModList.get().isLoaded("theoneprobe")) {
|
||||
InterModComms.sendTo("theoneprobe", "getTheOneProbe", TheOneProbeModule::new);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2020, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.theoneprobe;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import mcjty.theoneprobe.api.ITheOneProbe;
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.modules.theoneprobe.config.AEConfigProvider;
|
||||
|
||||
public class TheOneProbeModule implements IIntegrationModule, Function<ITheOneProbe, Void> {
|
||||
|
||||
@Override
|
||||
public Void apply(ITheOneProbe input) {
|
||||
input.registerProbeConfigProvider(new AEConfigProvider());
|
||||
input.registerProvider(new TileInfoProvider());
|
||||
input.registerProvider(new PartInfoProvider());
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.theoneprobe;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.text.TranslatableText;
|
||||
|
||||
public enum TheOneProbeText {
|
||||
CRAFTING, DEVICE_ONLINE, DEVICE_OFFLINE, DEVICE_MISSING_CHANNEL, P2P_UNLINKED, P2P_INPUT_ONE_OUTPUT,
|
||||
P2P_INPUT_MANY_OUTPUTS, P2P_OUTPUT, P2P_FREQUENCY, LOCKED, UNLOCKED, SHOWING, CONTAINS, CHANNELS, STORED_ENERGY;
|
||||
|
||||
private final String root;
|
||||
|
||||
TheOneProbeText() {
|
||||
this.root = "theoneprobe.appliedenergistics2";
|
||||
}
|
||||
|
||||
public String getTranslationString(Object... args) {
|
||||
return getTranslationComponent(args).getFormattedText();
|
||||
}
|
||||
|
||||
public TranslatableText getTranslationComponent(Object... args) {
|
||||
return new TranslatableText(this.getUnlocalized(), args);
|
||||
}
|
||||
|
||||
public String getUnlocalized() {
|
||||
return this.root + '.' + this.name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.theoneprobe;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.IProbeInfoProvider;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import appeng.integration.modules.theoneprobe.tile.ChargerInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.tile.CraftingMonitorInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.tile.ITileProbInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.tile.PowerStateInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.tile.PowerStorageInfoProvider;
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
|
||||
public final class TileInfoProvider implements IProbeInfoProvider {
|
||||
private final List<ITileProbInfoProvider> providers;
|
||||
|
||||
public TileInfoProvider() {
|
||||
final ITileProbInfoProvider charger = new ChargerInfoProvider();
|
||||
final ITileProbInfoProvider energyCell = new CraftingMonitorInfoProvider();
|
||||
final ITileProbInfoProvider craftingBlock = new PowerStateInfoProvider();
|
||||
final ITileProbInfoProvider craftingMonitor = new PowerStorageInfoProvider();
|
||||
|
||||
this.providers = Lists.newArrayList(charger, energyCell, craftingBlock, craftingMonitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return AppEng.MOD_ID + ":TileInfoProvider";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world,
|
||||
BlockState blockState, IProbeHitData data) {
|
||||
final BlockEntity tile = world.getBlockEntity(data.getPos());
|
||||
|
||||
if (tile instanceof AEBaseBlockEntity) {
|
||||
final AEBaseBlockEntity aeBaseTile = (AEBaseBlockEntity) tile;
|
||||
|
||||
for (final ITileProbInfoProvider provider : this.providers) {
|
||||
provider.addProbeInfo(aeBaseTile, mode, probeInfo, player, world, blockState, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.theoneprobe.config;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeConfig;
|
||||
import mcjty.theoneprobe.api.IProbeConfigProvider;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeHitEntityData;
|
||||
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
|
||||
public class AEConfigProvider implements IProbeConfigProvider {
|
||||
|
||||
@Override
|
||||
public void getProbeConfig(IProbeConfig config, PlayerEntity player, World world, Entity entity,
|
||||
IProbeHitEntityData data) {
|
||||
// Still no AE entities.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getProbeConfig(IProbeConfig config, PlayerEntity player, World world, BlockState blockState,
|
||||
IProbeHitData data) {
|
||||
if (world.getBlockEntity(data.getPos()) instanceof AEBaseBlockEntity) {
|
||||
config.setRFMode(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.parts.networking.SmartCablePart;
|
||||
import appeng.parts.networking.SmartDenseCablePart;
|
||||
|
||||
public class ChannelInfoProvider implements IPartProbInfoProvider {
|
||||
|
||||
@Override
|
||||
public void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world,
|
||||
BlockState blockState, IProbeHitData data) {
|
||||
if (part instanceof SmartDenseCablePart || part instanceof SmartCablePart) {
|
||||
final int usedChannels;
|
||||
final int maxChannels = (part instanceof SmartDenseCablePart) ? 32 : 8;
|
||||
|
||||
if (part.getGridNode().isActive()) {
|
||||
final CompoundTag tmp = new CompoundTag();
|
||||
part.writeToNBT(tmp);
|
||||
usedChannels = tmp.getByte("usedChannels");
|
||||
} else {
|
||||
usedChannels = 0;
|
||||
}
|
||||
|
||||
final String formattedChannelString = TheOneProbeText.CHANNELS.getTranslationString(usedChannels,
|
||||
maxChannels);
|
||||
|
||||
probeInfo.text(formattedChannelString);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.IProbeInfoProvider;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
|
||||
/**
|
||||
* Similar to {@link IProbeInfoProvider}, but already providing the
|
||||
* {@link IPart} being looked at.
|
||||
*
|
||||
*/
|
||||
public interface IPartProbInfoProvider {
|
||||
|
||||
/**
|
||||
* @see IProbeInfoProvider#addProbeInfo(ProbeMode, IProbeInfo, EntityPlayer,
|
||||
* World, IBlockState, IProbeHitData)
|
||||
*/
|
||||
void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world,
|
||||
BlockState blockState, IProbeHitData data);
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.p2p.P2PTunnelPart;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class P2PStateInfoProvider implements IPartProbInfoProvider {
|
||||
|
||||
private static final int STATE_UNLINKED = 0;
|
||||
private static final int STATE_OUTPUT = 1;
|
||||
private static final int STATE_INPUT = 2;
|
||||
|
||||
@Override
|
||||
public void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world,
|
||||
BlockState blockState, IProbeHitData data) {
|
||||
if (part instanceof P2PTunnelPart) {
|
||||
final P2PTunnelPart tunnel = (P2PTunnelPart) part;
|
||||
|
||||
if (!tunnel.isPowered()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The default state
|
||||
int state = STATE_UNLINKED;
|
||||
int outputCount = 0;
|
||||
|
||||
if (!tunnel.isOutput()) {
|
||||
outputCount = getOutputCount(tunnel);
|
||||
if (outputCount > 0) {
|
||||
// Only set it to INPUT if we know there are any outputs
|
||||
state = STATE_INPUT;
|
||||
}
|
||||
} else {
|
||||
final P2PTunnelPart input = tunnel.getInput();
|
||||
if (input != null) {
|
||||
state = STATE_OUTPUT;
|
||||
}
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case STATE_UNLINKED:
|
||||
probeInfo.text(TheOneProbeText.P2P_UNLINKED.getTranslationString());
|
||||
break;
|
||||
case STATE_OUTPUT:
|
||||
probeInfo.text(TheOneProbeText.P2P_OUTPUT.getTranslationString());
|
||||
break;
|
||||
case STATE_INPUT:
|
||||
probeInfo.text(getOutputText(outputCount));
|
||||
break;
|
||||
}
|
||||
|
||||
final short freq = tunnel.getFrequency();
|
||||
final String freqTooltip = Platform.p2p().toHexString(freq);
|
||||
|
||||
probeInfo.text(freqTooltip);
|
||||
}
|
||||
}
|
||||
|
||||
private static int getOutputCount(P2PTunnelPart tunnel) {
|
||||
try {
|
||||
return Iterators.size(tunnel.getOutputs().iterator());
|
||||
} catch (GridAccessException e) {
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getOutputText(int outputs) {
|
||||
if (outputs <= 1) {
|
||||
return TheOneProbeText.P2P_INPUT_ONE_OUTPUT.getTranslationString();
|
||||
} else {
|
||||
return TheOneProbeText.P2P_INPUT_MANY_OUTPUTS.getTranslationString(outputs);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
|
||||
public final class PartAccessor {
|
||||
|
||||
public Optional<IPart> getMaybePart(final BlockEntity te, final IProbeHitData data) {
|
||||
if (te instanceof IPartHost) {
|
||||
BlockPos pos = data.getPos();
|
||||
final Vec3d position = data.getHitPos().add(-pos.getX(), -pos.getY(), -pos.getZ());
|
||||
final IPartHost host = (IPartHost) te;
|
||||
final SelectedPart sp = host.selectPart(position);
|
||||
|
||||
if (sp.part != null) {
|
||||
return Optional.of(sp.part);
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
|
||||
public class PowerStateInfoProvider implements IPartProbInfoProvider {
|
||||
|
||||
@Override
|
||||
public void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world,
|
||||
BlockState blockState, IProbeHitData data) {
|
||||
if (part instanceof IPowerChannelState) {
|
||||
final IPowerChannelState state = (IPowerChannelState) part;
|
||||
final String tooltip = this.getToolTip(state.isActive(), state.isPowered());
|
||||
|
||||
probeInfo.text(tooltip);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getToolTip(final boolean isActive, final boolean isPowered) {
|
||||
final String result;
|
||||
|
||||
if (isActive && isPowered) {
|
||||
result = TheOneProbeText.DEVICE_ONLINE.getTranslationString();
|
||||
} else if (isPowered) {
|
||||
result = TheOneProbeText.DEVICE_MISSING_CHANNEL.getTranslationString();
|
||||
} else {
|
||||
result = TheOneProbeText.DEVICE_OFFLINE.getTranslationString();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.theoneprobe.part;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.implementations.parts.IStorageMonitorPart;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
|
||||
public class StorageMonitorInfoProvider implements IPartProbInfoProvider {
|
||||
|
||||
@Override
|
||||
public void addProbeInfo(IPart part, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world,
|
||||
BlockState blockState, IProbeHitData data) {
|
||||
if (part instanceof IStorageMonitorPart) {
|
||||
final IStorageMonitorPart monitor = (IStorageMonitorPart) part;
|
||||
|
||||
final IAEStack<?> displayed = monitor.getDisplayed();
|
||||
final boolean isLocked = monitor.isLocked();
|
||||
|
||||
// TODO: generalize
|
||||
if (displayed instanceof IAEItemStack) {
|
||||
final IAEItemStack ais = (IAEItemStack) displayed;
|
||||
probeInfo.text(TheOneProbeText.SHOWING.getTranslationComponent() + ": "
|
||||
+ ais.asItemStackRepresentation().getName());
|
||||
} else if (displayed instanceof IAEFluidStack) {
|
||||
final IAEFluidStack ais = (IAEFluidStack) displayed;
|
||||
final String fluidName = I18n.format(ais.getFluidStack().getTranslationKey());
|
||||
final String text = TheOneProbeText.SHOWING.getTranslationComponent() + ": " + fluidName;
|
||||
|
||||
probeInfo.text(text);
|
||||
}
|
||||
|
||||
probeInfo.text(isLocked ? TheOneProbeText.LOCKED.getTranslationString()
|
||||
: TheOneProbeText.UNLOCKED.getTranslationString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.theoneprobe.tile;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
import mcjty.theoneprobe.api.ElementAlignment;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
import appeng.tile.misc.ChargerBlockEntity;
|
||||
|
||||
public class ChargerInfoProvider implements ITileProbInfoProvider {
|
||||
|
||||
@Override
|
||||
public void addProbeInfo(AEBaseBlockEntity tile, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player,
|
||||
World world, BlockState blockState, IProbeHitData data) {
|
||||
if (tile instanceof ChargerBlockEntity) {
|
||||
final ChargerBlockEntity charger = (ChargerBlockEntity) tile;
|
||||
final FixedItemInv chargerInventory = charger.getInternalInventory();
|
||||
final ItemStack chargingItem = chargerInventory.getInvStack(0);
|
||||
|
||||
if (!chargingItem.isEmpty()) {
|
||||
final String currentInventory = chargingItem.getName().getString();
|
||||
final IProbeInfo centerAlignedHorizontalLayout = probeInfo
|
||||
.horizontal(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER));
|
||||
|
||||
centerAlignedHorizontalLayout.item(chargingItem);
|
||||
centerAlignedHorizontalLayout.text(currentInventory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-61
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.theoneprobe.tile;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.ElementAlignment;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
import appeng.tile.crafting.CraftingMonitorBlockEntity;
|
||||
|
||||
public class CraftingMonitorInfoProvider implements ITileProbInfoProvider {
|
||||
|
||||
@Override
|
||||
public void addProbeInfo(AEBaseBlockEntity tile, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player,
|
||||
World world, BlockState blockState, IProbeHitData data) {
|
||||
if (tile instanceof CraftingMonitorBlockEntity) {
|
||||
final CraftingMonitorBlockEntity monitor = (CraftingMonitorBlockEntity) tile;
|
||||
final IAEItemStack displayStack = monitor.getJobProgress();
|
||||
|
||||
if (displayStack != null) {
|
||||
// TODO: check if OK
|
||||
final ItemStack itemStack = displayStack.asItemStackRepresentation();
|
||||
final String itemName = itemStack.getName().getString();
|
||||
final String formattedCrafting = TheOneProbeText.CRAFTING.getTranslationComponent(itemName)
|
||||
.getFormattedText();
|
||||
|
||||
final IProbeInfo centerAlignedHorizontalLayout = probeInfo
|
||||
.horizontal(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER));
|
||||
|
||||
centerAlignedHorizontalLayout.item(itemStack);
|
||||
centerAlignedHorizontalLayout.text(formattedCrafting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.theoneprobe.tile;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.IProbeInfoProvider;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
|
||||
/**
|
||||
* Similar to {@link IProbeInfoProvider}, but already providing the
|
||||
* {@link AEBaseBlockEntity} being looked at.
|
||||
*
|
||||
*/
|
||||
public interface ITileProbInfoProvider {
|
||||
|
||||
/**
|
||||
* @see IProbeInfoProvider#addProbeInfo(ProbeMode, IProbeInfo, EntityPlayer,
|
||||
* World, IBlockState, IProbeHitData)
|
||||
*/
|
||||
void addProbeInfo(AEBaseBlockEntity tile, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player, World world,
|
||||
BlockState blockState, IProbeHitData data);
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.theoneprobe.tile;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
|
||||
public class PowerStateInfoProvider implements ITileProbInfoProvider {
|
||||
|
||||
@Override
|
||||
public void addProbeInfo(AEBaseBlockEntity tile, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player,
|
||||
World world, BlockState blockState, IProbeHitData data) {
|
||||
if (tile instanceof IPowerChannelState) {
|
||||
final IPowerChannelState state = (IPowerChannelState) tile;
|
||||
|
||||
final boolean isActive = state.isActive();
|
||||
final boolean isPowered = state.isPowered();
|
||||
|
||||
if (isActive && isPowered) {
|
||||
probeInfo.text(TheOneProbeText.DEVICE_ONLINE.getTranslationString());
|
||||
} else if (isPowered) {
|
||||
probeInfo.text(TheOneProbeText.DEVICE_MISSING_CHANNEL.getTranslationString());
|
||||
} else {
|
||||
probeInfo.text(TheOneProbeText.DEVICE_OFFLINE.getTranslationString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-61
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.theoneprobe.tile;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.networking.energy.IAEPowerStorage;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PowerStorageInfoProvider implements ITileProbInfoProvider {
|
||||
|
||||
@Override
|
||||
public void addProbeInfo(AEBaseBlockEntity tile, ProbeMode mode, IProbeInfo probeInfo, PlayerEntity player,
|
||||
World world, BlockState blockState, IProbeHitData data) {
|
||||
if (tile instanceof IAEPowerStorage) {
|
||||
final IAEPowerStorage storage = (IAEPowerStorage) tile;
|
||||
final double maxPower = storage.getAEMaxPower();
|
||||
|
||||
if (maxPower > 0) {
|
||||
final long internalCurrentPower = (long) (storage.getAECurrentPower() * 100);
|
||||
|
||||
if (internalCurrentPower >= 0) {
|
||||
final long internalMaxPower = (long) (100 * maxPower);
|
||||
|
||||
final String formatCurrentPower = Platform.formatPowerLong(internalCurrentPower, false);
|
||||
final String formatMaxPower = Platform.formatPowerLong(internalMaxPower, false);
|
||||
final String formattedString = TheOneProbeText.STORED_ENERGY
|
||||
.getTranslationComponent(formatCurrentPower, formatMaxPower).getFormattedText();
|
||||
|
||||
probeInfo.text(formattedString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user