Removed unused tunnel types and files.

Added more tags, moved ender pearl dust to convention tag.
Added compatibility with TechReborn's chargers.
This commit is contained in:
Sebastian Hartte
2020-08-17 19:00:32 +02:00
parent cf656e1540
commit 739277ab64
18 changed files with 117 additions and 533 deletions
@@ -25,12 +25,8 @@ package appeng.api.config;
public enum TunnelType {
ME, // Network Tunnel
IC2_POWER, // EU Tunnel
FE_POWER, // Forge Energy tunnel
REDSTONE, // Redstone Tunnel
FLUID, // Fluid Tunnel
ITEM, // Item Tunnel
LIGHT, // Light Tunnel
BUNDLED_REDSTONE, // Bundled Redstone Tunnel
COMPUTER_MESSAGE // Computer Message Tunnel
}
@@ -71,10 +71,6 @@ public interface IParts {
IItemDefinition p2PTunnelFluids();
IItemDefinition p2PTunnelEU();
IItemDefinition p2PTunnelFE();
IItemDefinition p2PTunnelLight();
IItemDefinition cableAnchor();
@@ -34,6 +34,9 @@ public class ConventionTagProvider extends TagProvider {
addItemTag("red_dyes", Items.RED_DYE);
addItemTag("black_dyes", Items.BLACK_DYE);
addItemTag("certus_quartz_crystals", MATERIALS.certusQuartzCrystal(), MATERIALS.certusQuartzCrystalCharged());
addItemTag("certus_quartz_ores", BLOCKS.quartzOre(), BLOCKS.quartzOreCharged());
addItemTag("iron_ingots", Items.IRON_INGOT);
addItemTag("iron_ores", Items.IRON_ORE);
addItemTag("gold_ingots", Items.GOLD_INGOT);
@@ -49,6 +52,7 @@ public class ConventionTagProvider extends TagProvider {
addItemTag("wheat_crops", Items.WHEAT);
addItemTag("redstone_dusts", Items.REDSTONE);
addItemTag("ender_pearls", Items.ENDER_PEARL);
addItemTag("ender_pearl_dusts", MATERIALS.enderDust());
addItemTag("terracotta_blocks", Items.TERRACOTTA, Items.WHITE_TERRACOTTA, Items.ORANGE_TERRACOTTA,
Items.MAGENTA_TERRACOTTA, Items.LIGHT_BLUE_TERRACOTTA, Items.YELLOW_TERRACOTTA, Items.LIME_TERRACOTTA,
Items.PINK_TERRACOTTA, Items.GRAY_TERRACOTTA, Items.LIGHT_GRAY_TERRACOTTA, Items.CYAN_TERRACOTTA,
+18 -17
View File
@@ -18,6 +18,22 @@
package appeng.core;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.DoubleSupplier;
import java.util.stream.Collectors;
import net.minecraft.world.dimension.DimensionType;
import appeng.api.config.CondenserOutput;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.PowerUnits;
@@ -36,21 +52,6 @@ import appeng.core.config.IntegerOption;
import appeng.core.config.StringListOption;
import appeng.core.settings.TickRates;
import appeng.util.EnumCycler;
import net.minecraft.world.dimension.DimensionType;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.DoubleSupplier;
import java.util.stream.Collectors;
public final class AEConfig {
@@ -584,8 +585,8 @@ public final class AEConfig {
powerUsageMultiplier = PowerRatios.addDouble("UsageMultiplier", 1.0, 0.01, Double.MAX_VALUE);
ConfigSection integration = root.subsection("Integration");
powerTransactionLimitTechReborn = integration.addDouble("MaxTechRebornEnergyPerTransaction", 10000.0, 0.1, 1000000.0,
"The maximum amount of TechReborn energy units that can be transfered per operation.");
powerTransactionLimitTechReborn = integration.addDouble("MaxTechRebornEnergyPerTransaction", 10000.0, 0.1,
1000000.0, "The maximum amount of TechReborn energy units that can be transfered per operation.");
ConfigSection Condenser = root.subsection("Condenser");
condenserMatterBallsPower = Condenser.addInt("MatterBalls", 256);
@@ -35,6 +35,10 @@ import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import team.reborn.energy.Energy;
import team.reborn.energy.EnergyHandler;
import team.reborn.energy.EnergyHolder;
import appeng.api.config.Upgrades;
import appeng.api.definitions.IBlocks;
import appeng.api.definitions.IItems;
@@ -42,6 +46,7 @@ import appeng.api.definitions.IParts;
import appeng.api.features.IRegistryContainer;
import appeng.api.features.IWirelessTermHandler;
import appeng.api.features.IWorldGen;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.api.movable.IMovableRegistry;
import appeng.api.networking.IGridCacheRegistry;
import appeng.api.networking.crafting.ICraftingGrid;
@@ -52,6 +57,7 @@ import appeng.api.networking.spatial.ISpatialCache;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.networking.ticking.ITickManager;
import appeng.api.parts.CableRenderMode;
import appeng.block.AEBaseBlockItemChargeable;
import appeng.bootstrap.IBootstrapComponent;
import appeng.bootstrap.components.ITileEntityRegistrationComponent;
import appeng.client.render.effects.ParticleTypes;
@@ -108,6 +114,7 @@ import appeng.fluids.container.FluidStorageBusContainer;
import appeng.fluids.container.FluidTerminalContainer;
import appeng.fluids.registries.BasicFluidCellGuiHandler;
import appeng.hooks.ToolItemHook;
import appeng.integration.modules.trenergy.ItemPowerStorageAdapter;
import appeng.items.parts.FacadeItem;
import appeng.items.tools.NetworkToolItem;
import appeng.me.cache.CraftingGridCache;
@@ -164,6 +171,7 @@ public abstract class AppEngBase implements AppEng {
setupInternalRegistries();
ItemPowerStorageAdapter.register();
}
public static void setupInternalRegistries() {
@@ -105,8 +105,6 @@ public final class ApiParts implements IParts {
private final IItemDefinition p2PTunnelRedstone;
private final IItemDefinition p2PTunnelItems;
private final IItemDefinition p2PTunnelFluids;
private final IItemDefinition p2PTunnelEU;
private final IItemDefinition p2PTunnelFE;
private final IItemDefinition p2PTunnelLight;
private final IItemDefinition cableAnchor;
private final IItemDefinition monitor;
@@ -176,17 +174,11 @@ public final class ApiParts implements IParts {
RedstoneP2PTunnelPart::new);
this.p2PTunnelItems = createPart("item_p2p_tunnel", ItemP2PTunnelPart.class, ItemP2PTunnelPart::new);
this.p2PTunnelFluids = createPart("fluid_p2p_tunnel", FluidP2PTunnelPart.class, FluidP2PTunnelPart::new);
// FIXME FABRIC this.p2PTunnelEU = null; // FIXME createPart( "ic2_p2p_tunnel", PartType.P2P_TUNNEL_IC2,
// FIXME FABRIC // PartP2PIC2Power.class, PartP2PIC2Power::new);
// FIXME FABRIC this.p2PTunnelFE = createPart("fe_p2p_tunnel", FEP2PTunnelPart.class, FEP2PTunnelPart::new);
this.p2PTunnelLight = createPart("light_p2p_tunnel", LightP2PTunnelPart.class, LightP2PTunnelPart::new);
this.interfaceTerminal = createPart("interface_terminal", InterfaceTerminalPart.class,
InterfaceTerminalPart::new);
this.fluidTerminal = createPart("fluid_terminal", FluidTerminalPart.class, FluidTerminalPart::new);
this.p2PTunnelEU = null;
this.p2PTunnelFE = null;
this.registry = null;
this.partModels = null;
}
@@ -324,16 +316,6 @@ public final class ApiParts implements IParts {
return this.p2PTunnelFluids;
}
@Override
public IItemDefinition p2PTunnelEU() {
return this.p2PTunnelEU;
}
@Override
public IItemDefinition p2PTunnelFE() {
return this.p2PTunnelFE;
}
@Override
public IItemDefinition p2PTunnelLight() {
return this.p2PTunnelLight;
@@ -63,32 +63,6 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry {
this.addNewAttunement(new ItemStack(Blocks.TORCH), TunnelType.LIGHT);
this.addNewAttunement(new ItemStack(Blocks.GLOWSTONE), TunnelType.LIGHT);
/*
* Forge energy tunnel items
*/
this.addNewAttunement(blocks.energyCellDense(), TunnelType.FE_POWER);
this.addNewAttunement(blocks.energyAcceptor(), TunnelType.FE_POWER);
this.addNewAttunement(blocks.energyCell(), TunnelType.FE_POWER);
this.addNewAttunement(blocks.energyCellCreative(), TunnelType.FE_POWER);
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 0 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 1 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 2 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 3 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 4 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 5 ), TunnelType.FE_POWER );
/**
* EU tunnel items
*/
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 0 ), TunnelType.IC2_POWER ); // Copper cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 1 ), TunnelType.IC2_POWER ); // Glass fibre cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 2 ), TunnelType.IC2_POWER ); // Gold cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 3 ), TunnelType.IC2_POWER ); // HV cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 4 ), TunnelType.IC2_POWER ); // Tin cable
/**
* attune based on most redstone base items.
*/
@@ -114,16 +88,6 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry {
this.addNewAttunement(new ItemStack(Blocks.HOPPER), TunnelType.ITEM);
this.addNewAttunement(new ItemStack(Blocks.CHEST), TunnelType.ITEM);
this.addNewAttunement(new ItemStack(Blocks.TRAPPED_CHEST), TunnelType.ITEM);
// FIXME this.addNewAttunement( this.getModItem( "extrautilities", "extractor_base", 0 ), TunnelType.ITEM );
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "parttransmitter", 9 ), TunnelType.ITEM );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 0 ), TunnelType.ITEM ); // itemduct
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 1 ), TunnelType.ITEM ); // itemduct
// FIXME // (opaque)
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 2 ), TunnelType.ITEM ); // impulse
// FIXME // itemduct
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 3 ), TunnelType.ITEM ); // impulse
// FIXME // itemduct
// (opaque)
/**
* attune based on lots of random item related stuff
@@ -132,18 +96,7 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry {
this.addNewAttunement(new ItemStack(Items.LAVA_BUCKET), TunnelType.FLUID);
this.addNewAttunement(new ItemStack(Items.MILK_BUCKET), TunnelType.FLUID);
this.addNewAttunement(new ItemStack(Items.WATER_BUCKET), TunnelType.FLUID);
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "machineblock2", 11 ), TunnelType.FLUID );
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "parttransmitter", 4 ), TunnelType.FLUID );
// FIXME this.addNewAttunement( this.getModItem( "extrautilities", "extractor_base", 6 ), TunnelType.FLUID );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_16", 0 ), TunnelType.FLUID ); // fluiduct
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_16", 1 ), TunnelType.FLUID ); // fluiduct
// FIXME // (opaque)
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_16", 2 ), TunnelType.FLUID ); // fluiduct
// FIXME // hardened
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_16", 3 ), TunnelType.FLUID ); // fluiduct
// FIXME // hardened
// FIXME // (opaque)
// FIXME
for (final AEColor c : AEColor.values()) {
this.addNewAttunement(parts.cableGlass().stack(c, 1), TunnelType.ME);
this.addNewAttunement(parts.cableCovered().stack(c, 1), TunnelType.ME);
@@ -154,30 +107,11 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry {
/**
* attune based caps
*/
// FIXME FABRIC this.addNewAttunement(Capabilities.FORGE_ENERGY,
// TunnelType.FE_POWER);
this.addNewAttunement(FluidAttributes.EXTRACTABLE, TunnelType.FLUID);
this.addNewAttunement(FluidAttributes.INSERTABLE, TunnelType.FLUID);
this.addNewAttunement(FluidAttributes.FIXED_INV, TunnelType.FLUID);
this.addNewAttunement(FluidAttributes.GROUPED_INV, TunnelType.FLUID);
/**
* attune based on the ItemStack's modId
*/
this.addNewAttunement("thermaldynamics", TunnelType.FE_POWER);
this.addNewAttunement("thermalexpansion", TunnelType.FE_POWER);
this.addNewAttunement("thermalfoundation", TunnelType.FE_POWER);
// TODO: Remove when confirmed that the official 1.12 version of EnderIO will
// support FE.
this.addNewAttunement("enderio", TunnelType.FE_POWER);
// TODO: Remove when confirmed that the official 1.12 version of Mekanism will
// support FE.
this.addNewAttunement("mekanism", TunnelType.FE_POWER);
// TODO: Remove when support for RFTools' Powercells support is added
this.addNewAttunement("rftools", TunnelType.FE_POWER);
this.addNewAttunement("ic2", TunnelType.IC2_POWER);
}
@Override
@@ -128,6 +128,10 @@ public class FluidImportBusPart extends SharedFluidBusPart {
aeFluidStack.decStackSize(notInserted.getStackSize());
}
if (aeFluidStack.getStackSize() == 0) {
return TickRateModulation.SLOWER;
}
// Now we need to actually drain the fluid, and use the actual amount we just
// inserted
extractable.extract(filter, aeFluidStack.getAmount()); // FIXME: If there's a mismatch here, log?
@@ -0,0 +1,66 @@
package appeng.integration.modules.trenergy;
import net.minecraft.item.ItemStack;
import team.reborn.energy.Energy;
import team.reborn.energy.EnergySide;
import team.reborn.energy.EnergyStorage;
import team.reborn.energy.EnergyTier;
import appeng.api.config.Actionable;
import appeng.api.config.PowerUnits;
import appeng.api.implementations.items.IAEItemPowerStorage;
/**
* Adapts an itemstack that implements
* {@link appeng.api.implementations.items.IAEItemPowerStorage} to the interface
* used by TechReborn's energy API.
*/
public final class ItemPowerStorageAdapter implements EnergyStorage {
private final IAEItemPowerStorage item;
private final ItemStack stack;
public ItemPowerStorageAdapter(IAEItemPowerStorage item, ItemStack stack) {
this.item = item;
this.stack = stack;
}
@Override
public double getStored(EnergySide energySide) {
return PowerUnits.AE.convertTo(PowerUnits.TR, this.item.getAECurrentPower(this.stack));
}
@Override
public void setStored(double v) {
double newPower = PowerUnits.TR.convertTo(PowerUnits.AE, v);
double currentPower = this.item.getAECurrentPower(this.stack);
double toInject = newPower - currentPower;
if (toInject > 0.0000001) {
this.item.injectAEPower(stack, toInject, Actionable.MODULATE);
}
}
@Override
public double getMaxStoredPower() {
return PowerUnits.AE.convertTo(PowerUnits.TR, this.item.getAEMaxPower(this.stack));
}
@Override
public EnergyTier getTier() {
return EnergyTier.INFINITE;
}
public static void register() {
// Register our charged items as TechReborn Energy compatible
Energy.registerHolder(
(Object obj) -> obj instanceof ItemStack && ((ItemStack) obj).getItem() instanceof IAEItemPowerStorage,
(Object obj) -> {
ItemStack stack = (ItemStack) obj;
IAEItemPowerStorage item = (IAEItemPowerStorage) stack.getItem();
return new ItemPowerStorageAdapter(item, stack);
});
}
}
@@ -218,18 +218,10 @@ public abstract class P2PTunnelPart<T extends P2PTunnelPart> extends BasicStateP
newType = parts.p2PTunnelLight().maybeStack(1).orElse(ItemStack.EMPTY);
break;
case FE_POWER:
newType = parts.p2PTunnelFE().maybeStack(1).orElse(ItemStack.EMPTY);
break;
case FLUID:
newType = parts.p2PTunnelFluids().maybeStack(1).orElse(ItemStack.EMPTY);
break;
case IC2_POWER:
newType = parts.p2PTunnelEU().maybeStack(1).orElse(ItemStack.EMPTY);
break;
case ITEM:
newType = parts.p2PTunnelItems().maybeStack(1).orElse(ItemStack.EMPTY);
break;
@@ -242,12 +234,6 @@ public abstract class P2PTunnelPart<T extends P2PTunnelPart> extends BasicStateP
newType = parts.p2PTunnelRedstone().maybeStack(1).orElse(ItemStack.EMPTY);
break;
/*
* case COMPUTER_MESSAGE: for( ItemStack stack :
* parts.p2PTunnelOpenComputers().maybeStack( 1 ).asSet() ) { newType = stack; }
* break;
*/
default:
newType = ItemStack.EMPTY;
break;
@@ -18,6 +18,21 @@
package appeng.tile.powersink;
import java.util.EnumSet;
import java.util.Set;
import com.google.common.collect.ImmutableSet;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import team.reborn.energy.EnergySide;
import team.reborn.energy.EnergyStorage;
import team.reborn.energy.EnergyTier;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
@@ -26,18 +41,6 @@ import appeng.api.networking.energy.IAEPowerStorage;
import appeng.api.networking.events.MENetworkPowerStorage.PowerEventType;
import appeng.core.AEConfig;
import appeng.tile.AEBaseInvBlockEntity;
import com.google.common.collect.ImmutableSet;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import team.reborn.energy.EnergySide;
import team.reborn.energy.EnergyStorage;
import team.reborn.energy.EnergyTier;
import java.util.EnumSet;
import java.util.Set;
public abstract class AEBasePoweredBlockEntity extends AEBaseInvBlockEntity
implements IAEPowerStorage, IExternalPowerSink, EnergyStorage {
@@ -16,7 +16,7 @@
"tag": "appliedenergistics2:dusts/fluix"
},
"c": {
"tag": "appliedenergistics2:dusts/ender"
"tag": "c:ender_pearl_dusts"
}
}
}
@@ -1,3 +0,0 @@
{
"values": ["appliedenergistics2:ender_dust"]
}
@@ -1,92 +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.items.tools.powered.powersink;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.IEnergyStorage;
import appeng.api.config.Actionable;
import appeng.api.config.PowerUnits;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.attributes.MEAttributes;
/**
* The capability provider to expose chargable items to other mods.
*/
class PoweredItemCapabilities implements ICapabilityProvider, IEnergyStorage {
private final ItemStack is;
private final IAEItemPowerStorage item;
PoweredItemCapabilities(ItemStack is, IAEItemPowerStorage item) {
this.is = is;
this.item = item;
}
@SuppressWarnings("unchecked")
@Override
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing) {
if (capability == MEAttributes.FORGE_ENERGY) {
return (LazyOptional<T>) LazyOptional.of(() -> this);
}
return LazyOptional.empty();
}
@Override
public int receiveEnergy(int maxReceive, boolean simulate) {
final double convertedOffer = PowerUnits.TR.convertTo(PowerUnits.AE, maxReceive);
final double overflow = this.item.injectAEPower(this.is, convertedOffer,
simulate ? Actionable.SIMULATE : Actionable.MODULATE);
return maxReceive - (int) PowerUnits.AE.convertTo(PowerUnits.TR, overflow);
}
@Override
public int extractEnergy(int maxExtract, boolean simulate) {
return 0;
}
@Override
public int getEnergyStored() {
return (int) PowerUnits.AE.convertTo(PowerUnits.TR, this.item.getAECurrentPower(this.is));
}
@Override
public int getMaxEnergyStored() {
return (int) PowerUnits.AE.convertTo(PowerUnits.TR, this.item.getAEMaxPower(this.is));
}
@Override
public boolean canExtract() {
return false;
}
@Override
public boolean canReceive() {
return true;
}
}
@@ -1,244 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2017, 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.parts.p2p;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.IEnergyStorage;
import appeng.api.config.PowerUnits;
import appeng.api.parts.IPartModel;
import appeng.attributes.MEAttributes;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
public class FEP2PTunnelPart extends P2PTunnelPart<FEP2PTunnelPart> {
private static final P2PModels MODELS = new P2PModels("part/p2p/p2p_tunnel_fe");
private static final IEnergyStorage NULL_ENERGY_STORAGE = new NullEnergyStorage();
private final IEnergyStorage inputHandler = new InputEnergyStorage();
private final IEnergyStorage outputHandler = new OutputEnergyStorage();
public FEP2PTunnelPart(ItemStack is) {
super(is);
}
@Override
protected float getPowerDrainPerTick() {
return 2.0f;
}
@PartModels
public static List<IPartModel> getModels() {
return MODELS.getModels();
}
@Override
public IPartModel getStaticModels() {
return MODELS.getModel(this.isPowered(), this.isActive());
}
@Override
public void onTunnelNetworkChange() {
this.getHost().notifyNeighbors();
}
private IEnergyStorage getAttachedEnergyStorage() {
LazyOptional<IEnergyStorage> energyStorageOpt = LazyOptional.empty();
if (this.isActive()) {
final BlockEntity self = this.getTile();
final BlockEntity te = self.getWorld().getBlockEntity(self.getPos().offset(this.getSide().getFacing()));
if (te != null) {
energyStorageOpt = te.getCapability(MEAttributes.FORGE_ENERGY,
this.getSide().getOpposite().getFacing());
}
}
return energyStorageOpt.orElse(NULL_ENERGY_STORAGE);
}
@SuppressWarnings("unchecked")
@Nullable
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability) {
if (capability == MEAttributes.FORGE_ENERGY) {
if (this.isOutput()) {
return (LazyOptional<T>) LazyOptional.of(() -> this.outputHandler);
}
return (LazyOptional<T>) LazyOptional.of(() -> this.inputHandler);
}
return super.getCapability(capability);
}
private class InputEnergyStorage implements IEnergyStorage {
@Override
public int extractEnergy(int maxExtract, boolean simulate) {
return 0;
}
@Override
public int receiveEnergy(int maxReceive, boolean simulate) {
int total = 0;
try {
final int outputTunnels = FEP2PTunnelPart.this.getOutputs().size();
if (outputTunnels == 0 | maxReceive == 0) {
return 0;
}
final int amountPerOutput = maxReceive / outputTunnels;
int overflow = amountPerOutput == 0 ? maxReceive : maxReceive % amountPerOutput;
for (FEP2PTunnelPart target : FEP2PTunnelPart.this.getOutputs()) {
final IEnergyStorage output = target.getAttachedEnergyStorage();
final int toSend = amountPerOutput + overflow;
final int received = output.receiveEnergy(toSend, simulate);
overflow = toSend - received;
total += received;
}
if (!simulate) {
FEP2PTunnelPart.this.queueTunnelDrain(PowerUnits.TR, total);
}
} catch (GridAccessException ignored) {
}
return total;
}
@Override
public boolean canExtract() {
return false;
}
@Override
public boolean canReceive() {
return true;
}
@Override
public int getMaxEnergyStored() {
int total = 0;
try {
for (FEP2PTunnelPart t : FEP2PTunnelPart.this.getOutputs()) {
total += t.getAttachedEnergyStorage().getMaxEnergyStored();
}
} catch (GridAccessException e) {
return 0;
}
return total;
}
@Override
public int getEnergyStored() {
int total = 0;
try {
for (FEP2PTunnelPart t : FEP2PTunnelPart.this.getOutputs()) {
total += t.getAttachedEnergyStorage().getEnergyStored();
}
} catch (GridAccessException e) {
return 0;
}
return total;
}
}
private class OutputEnergyStorage implements IEnergyStorage {
@Override
public int extractEnergy(int maxExtract, boolean simulate) {
final int total = FEP2PTunnelPart.this.getAttachedEnergyStorage().extractEnergy(maxExtract, simulate);
if (!simulate) {
FEP2PTunnelPart.this.queueTunnelDrain(PowerUnits.TR, total);
}
return total;
}
@Override
public int receiveEnergy(int maxReceive, boolean simulate) {
return 0;
}
@Override
public boolean canExtract() {
return FEP2PTunnelPart.this.getAttachedEnergyStorage().canExtract();
}
@Override
public boolean canReceive() {
return false;
}
@Override
public int getMaxEnergyStored() {
return FEP2PTunnelPart.this.getAttachedEnergyStorage().getMaxEnergyStored();
}
@Override
public int getEnergyStored() {
return FEP2PTunnelPart.this.getAttachedEnergyStorage().getEnergyStored();
}
}
private static class NullEnergyStorage implements IEnergyStorage {
@Override
public int receiveEnergy(int maxReceive, boolean simulate) {
return 0;
}
@Override
public int extractEnergy(int maxExtract, boolean simulate) {
return 0;
}
@Override
public int getEnergyStored() {
return 0;
}
@Override
public int getMaxEnergyStored() {
return 0;
}
@Override
public boolean canExtract() {
return false;
}
@Override
public boolean canReceive() {
return false;
}
}
}
@@ -1,22 +0,0 @@
# GUI rendering
protected net.minecraft.client.gui.screen.inventory.ContainerScreen func_238746_a_(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/inventory/container/Slot;)V # moveItems
public net.minecraft.client.gui.widget.TextFieldWidget func_146188_c(IIII)V # drawSelectionBox
public net.minecraft.client.gui.widget.TextFieldWidget func_146208_g()I # getMaxStringLength
protected net.minecraft.inventory.container.Container field_75149_d # listeners
# Reusing RedstoneParticle for ChargedOreFX
protected net.minecraft.client.particle.RedstoneParticle <init>(Lnet/minecraft/client/world/ClientWorld;DDDDDDLnet/minecraft/particles/RedstoneParticleData;Lnet/minecraft/client/particle/IAnimatedSprite;)V
# We need to change yPos of existing slots to resize the container
public-f net.minecraft.inventory.container.Slot field_75223_e # xPos
public-f net.minecraft.inventory.container.Slot field_75221_f # yPos
# For JEI registration
public net.minecraft.item.crafting.RecipeManager func_215366_a(Lnet/minecraft/item/crafting/IRecipeType;)Ljava/util/Map; # getRecipes
# To disable water-bobbing of item entities (for growing crystals)
protected net.minecraft.entity.item.ItemEntity func_203043_v()V # applyFloatMotion
# Registration of custom DimensionType
public net.minecraft.world.DimensionType <init>(Ljava/util/OptionalLong;ZZZZZZZZZILnet/minecraft/util/ResourceLocation;F)V
-29
View File
@@ -1,29 +0,0 @@
modLoader="javafml"
loaderVersion="[32,)"
#updateJSONURL=""
issueTrackerURL="https://github.com/AppliedEnergistics/Applied-Energistics-2/issues"
displayURL="https://github.com/AppliedEnergistics/Applied-Energistics-2"
logoFile="logo.png"
#credits="Thanks for this example mod goes to Java"
authors="TeamAppliedEnergistics"
license="See GitHub repository for details"
[[mods]]
modId="appliedenergistics2"
version="${file.jarVersion}"
displayName="Applied Energistics 2"
description="A Mod about Matter, Energy and using them to conquer the world.."
[[dependencies.appliedenergistics2]]
modId="forge"
mandatory=true
versionRange="[33.0.5,34.0.0)"
ordering="NONE"
side="BOTH"
[[dependencies.appliedenergistics2]]
modId="minecraft"
mandatory=true
versionRange="[1.16.2]"
ordering="NONE"
side="BOTH"
-6
View File
@@ -1,6 +0,0 @@
{
"pack": {
"pack_format": 5,
"description": "Resources used for Applied Energistics 2"
}
}