Part type's gone!

This commit is contained in:
Sebastian Hartte
2020-07-02 12:05:34 +02:00
parent 25da0b7357
commit fe439bfb23
2 changed files with 74 additions and 260 deletions
@@ -21,7 +21,6 @@ package appeng.core.api.definitions;
import java.util.function.Function;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IParts;
@@ -29,55 +28,21 @@ import appeng.api.parts.IPart;
import appeng.api.util.AEColor;
import appeng.api.util.AEColoredItemDefinition;
import appeng.bootstrap.FeatureFactory;
import appeng.core.AppEng;
import appeng.core.CreativeTab;
import appeng.core.features.ActivityState;
import appeng.core.features.ColoredItemDefinition;
import appeng.core.features.ItemStackSrc;
import appeng.core.features.registries.PartModels;
import appeng.fluids.parts.FluidAnnihilationPlanePart;
import appeng.fluids.parts.FluidExportBusPart;
import appeng.fluids.parts.FluidFormationPlanePart;
import appeng.fluids.parts.FluidImportBusPart;
import appeng.fluids.parts.FluidInterfacePart;
import appeng.fluids.parts.FluidLevelEmitterPart;
import appeng.fluids.parts.FluidStorageBusPart;
import appeng.fluids.parts.FluidTerminalPart;
import appeng.fluids.parts.*;
import appeng.items.parts.ColoredPartItem;
import appeng.items.parts.PartItem;
import appeng.items.parts.PartItemRendering;
import appeng.parts.automation.AnnihilationPlanePart;
import appeng.parts.automation.ExportBusPart;
import appeng.parts.automation.FormationPlanePart;
import appeng.parts.automation.IdentityAnnihilationPlanePart;
import appeng.parts.automation.ImportBusPart;
import appeng.parts.automation.LevelEmitterPart;
import appeng.parts.misc.CableAnchorPart;
import appeng.parts.misc.InterfacePart;
import appeng.parts.misc.InvertedToggleBusPart;
import appeng.parts.misc.StorageBusPart;
import appeng.parts.misc.ToggleBusPart;
import appeng.parts.networking.CoveredCablePart;
import appeng.parts.networking.CoveredDenseCablePart;
import appeng.parts.networking.GlassCablePart;
import appeng.parts.networking.QuartzFiberPart;
import appeng.parts.networking.SmartCablePart;
import appeng.parts.networking.SmartDenseCablePart;
import appeng.parts.p2p.FEP2PTunnelPart;
import appeng.parts.p2p.FluidP2PTunnelPart;
import appeng.parts.p2p.ItemP2PTunnelPart;
import appeng.parts.p2p.LightP2PTunnelPart;
import appeng.parts.p2p.MEP2PTunnelPart;
import appeng.parts.p2p.RedstoneP2PTunnelPart;
import appeng.parts.reporting.ConversionMonitorPart;
import appeng.parts.reporting.CraftingTerminalPart;
import appeng.parts.reporting.DarkPanelPart;
import appeng.parts.reporting.InterfaceTerminalPart;
import appeng.parts.reporting.PanelPart;
import appeng.parts.reporting.PatternTerminalPart;
import appeng.parts.reporting.SemiDarkPanelPart;
import appeng.parts.reporting.StorageMonitorPart;
import appeng.parts.reporting.TerminalPart;
import appeng.items.parts.PartModelsHelper;
import appeng.parts.automation.*;
import appeng.parts.misc.*;
import appeng.parts.networking.*;
import appeng.parts.p2p.*;
import appeng.parts.reporting.*;
/**
* Internal implementation for the API parts
@@ -125,77 +90,85 @@ public final class ApiParts implements IParts {
private final IItemDefinition fluidTerminal;
private final IItemDefinition fluidStorageBus;
private FeatureFactory registry;
private PartModels partModels;
public ApiParts(FeatureFactory registry, PartModels partModels) {
registerPartModels(partModels);
this.registry = registry;
this.partModels = partModels;
this.cableSmart = constructColoredDefinition(registry, "smart_cable", SmartCablePart::new);
this.cableCovered = constructColoredDefinition(registry, "covered_cable", CoveredCablePart::new);
this.cableGlass = constructColoredDefinition(registry, "glass_cable", GlassCablePart::new);
this.cableDenseCovered = constructColoredDefinition(registry, "covered_dense_cable",
this.cableSmart = constructColoredDefinition("smart_cable", SmartCablePart.class, SmartCablePart::new);
this.cableCovered = constructColoredDefinition("covered_cable", CoveredCablePart.class, CoveredCablePart::new);
this.cableGlass = constructColoredDefinition("glass_cable", GlassCablePart.class, GlassCablePart::new);
this.cableDenseCovered = constructColoredDefinition("covered_dense_cable", CoveredDenseCablePart.class,
CoveredDenseCablePart::new);
this.cableDenseSmart = constructColoredDefinition(registry, "smart_dense_cable", SmartDenseCablePart::new);
this.quartzFiber = createPart(registry, "quartz_fiber", QuartzFiberPart::new);
this.toggleBus = createPart(registry, "toggle_bus", ToggleBusPart::new);
this.invertedToggleBus = createPart(registry, "inverted_toggle_bus", InvertedToggleBusPart::new);
this.cableAnchor = createPart(registry, "cable_anchor", CableAnchorPart::new);
this.monitor = createPart(registry, "monitor", PanelPart::new);
this.semiDarkMonitor = createPart(registry, "semi_dark_monitor", SemiDarkPanelPart::new);
this.darkMonitor = createPart(registry, "dark_monitor", DarkPanelPart::new);
this.storageBus = createPart(registry, "storage_bus", StorageBusPart::new);
this.fluidStorageBus = createPart(registry, "fluid_storage_bus", FluidStorageBusPart::new);
this.importBus = createPart(registry, "import_bus", ImportBusPart::new);
this.fluidImportBus = createPart(registry, "fluid_import_bus", FluidImportBusPart::new);
this.exportBus = createPart(registry, "export_bus", ExportBusPart::new);
this.fluidExportBus = createPart(registry, "fluid_export_bus", FluidExportBusPart::new);
this.levelEmitter = createPart(registry, "level_emitter", LevelEmitterPart::new);
this.fluidLevelEmitter = createPart(registry, "fluid_level_emitter", FluidLevelEmitterPart::new);
this.annihilationPlane = createPart(registry, "annihilation_plane", AnnihilationPlanePart::new);
this.identityAnnihilationPlane = createPart(registry, "identity_annihilation_plane",
this.cableDenseSmart = constructColoredDefinition("smart_dense_cable", SmartDenseCablePart.class,
SmartDenseCablePart::new);
this.quartzFiber = createPart("quartz_fiber", QuartzFiberPart.class, QuartzFiberPart::new);
this.toggleBus = createPart("toggle_bus", ToggleBusPart.class, ToggleBusPart::new);
this.invertedToggleBus = createPart("inverted_toggle_bus", InvertedToggleBusPart.class,
InvertedToggleBusPart::new);
this.cableAnchor = createPart("cable_anchor", CableAnchorPart.class, CableAnchorPart::new);
this.monitor = createPart("monitor", PanelPart.class, PanelPart::new);
this.semiDarkMonitor = createPart("semi_dark_monitor", SemiDarkPanelPart.class, SemiDarkPanelPart::new);
this.darkMonitor = createPart("dark_monitor", DarkPanelPart.class, DarkPanelPart::new);
this.storageBus = createPart("storage_bus", StorageBusPart.class, StorageBusPart::new);
this.fluidStorageBus = createPart("fluid_storage_bus", FluidStorageBusPart.class, FluidStorageBusPart::new);
this.importBus = createPart("import_bus", ImportBusPart.class, ImportBusPart::new);
this.fluidImportBus = createPart("fluid_import_bus", FluidImportBusPart.class, FluidImportBusPart::new);
this.exportBus = createPart("export_bus", ExportBusPart.class, ExportBusPart::new);
this.fluidExportBus = createPart("fluid_export_bus", FluidExportBusPart.class, FluidExportBusPart::new);
this.levelEmitter = createPart("level_emitter", LevelEmitterPart.class, LevelEmitterPart::new);
this.fluidLevelEmitter = createPart("fluid_level_emitter", FluidLevelEmitterPart.class,
FluidLevelEmitterPart::new);
this.annihilationPlane = createPart("annihilation_plane", AnnihilationPlanePart.class,
AnnihilationPlanePart::new);
this.identityAnnihilationPlane = createPart("identity_annihilation_plane", IdentityAnnihilationPlanePart.class,
IdentityAnnihilationPlanePart::new);
this.fluidAnnihilationPlane = createPart(registry, "fluid_annihilation_plane", FluidAnnihilationPlanePart::new);
this.formationPlane = createPart(registry, "formation_plane", FormationPlanePart::new);
this.fluidFormationPlane = createPart(registry, "fluid_formation_plane", FluidFormationPlanePart::new);
this.patternTerminal = createPart(registry, "pattern_terminal", PatternTerminalPart::new);
this.craftingTerminal = createPart(registry, "crafting_terminal", CraftingTerminalPart::new);
this.terminal = createPart(registry, "terminal", TerminalPart::new);
this.storageMonitor = createPart(registry, "storage_monitor", StorageMonitorPart::new);
this.conversionMonitor = createPart(registry, "conversion_monitor", ConversionMonitorPart::new);
this.iface = createPart(registry, "cable_interface", InterfacePart::new);
this.fluidIface = createPart(registry, "cable_fluid_interface", FluidInterfacePart::new);
this.p2PTunnelME = createPart(registry, "me_p2p_tunnel", MEP2PTunnelPart::new);
this.p2PTunnelRedstone = createPart(registry, "redstone_p2p_tunnel", RedstoneP2PTunnelPart::new);
this.p2PTunnelItems = createPart(registry, "item_p2p_tunnel", ItemP2PTunnelPart::new);
this.p2PTunnelFluids = createPart(registry, "fluid_p2p_tunnel", FluidP2PTunnelPart::new);
this.fluidAnnihilationPlane = createPart("fluid_annihilation_plane", FluidAnnihilationPlanePart.class,
FluidAnnihilationPlanePart::new);
this.formationPlane = createPart("formation_plane", FormationPlanePart.class, FormationPlanePart::new);
this.fluidFormationPlane = createPart("fluid_formation_plane", FluidFormationPlanePart.class,
FluidFormationPlanePart::new);
this.patternTerminal = createPart("pattern_terminal", PatternTerminalPart.class, PatternTerminalPart::new);
this.craftingTerminal = createPart("crafting_terminal", CraftingTerminalPart.class, CraftingTerminalPart::new);
this.terminal = createPart("terminal", TerminalPart.class, TerminalPart::new);
this.storageMonitor = createPart("storage_monitor", StorageMonitorPart.class, StorageMonitorPart::new);
this.conversionMonitor = createPart("conversion_monitor", ConversionMonitorPart.class,
ConversionMonitorPart::new);
this.iface = createPart("cable_interface", InterfacePart.class, InterfacePart::new);
this.fluidIface = createPart("cable_fluid_interface", FluidInterfacePart.class, FluidInterfacePart::new);
this.p2PTunnelME = createPart("me_p2p_tunnel", MEP2PTunnelPart.class, MEP2PTunnelPart::new);
this.p2PTunnelRedstone = createPart("redstone_p2p_tunnel", RedstoneP2PTunnelPart.class,
RedstoneP2PTunnelPart::new);
this.p2PTunnelItems = createPart("item_p2p_tunnel", ItemP2PTunnelPart.class, ItemP2PTunnelPart::new);
this.p2PTunnelFluids = createPart("fluid_p2p_tunnel", FluidP2PTunnelPart.class, FluidP2PTunnelPart::new);
this.p2PTunnelEU = null; // FIXME createPart( "ic2_p2p_tunnel", PartType.P2P_TUNNEL_IC2,
// PartP2PIC2Power::new);
this.p2PTunnelFE = createPart(registry, "fe_p2p_tunnel", FEP2PTunnelPart::new);
this.p2PTunnelLight = createPart(registry, "light_p2p_tunnel", LightP2PTunnelPart::new);
this.interfaceTerminal = createPart(registry, "interface_terminal", InterfaceTerminalPart::new);
this.fluidTerminal = createPart(registry, "fluid_terminal", FluidTerminalPart::new);
// PartP2PIC2Power.class, PartP2PIC2Power::new);
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.registry = null;
this.partModels = null;
}
private void registerPartModels(PartModels partModels) {
// Register the built-in models for annihilation planes
ResourceLocation fluidFormationPlaneTexture = new ResourceLocation(AppEng.MOD_ID,
"item/part/fluid_formation_plane");
ResourceLocation fluidFormationPlaneOnTexture = new ResourceLocation(AppEng.MOD_ID,
"parts/fluid_formation_plane_on");
// Register all part models
for (PartType partType : PartType.values()) {
partModels.registerModels(partType.getModels());
}
}
private <T extends IPart> IItemDefinition createPart(FeatureFactory registry, String id,
private <T extends IPart> IItemDefinition createPart(String id, Class<T> partClass,
Function<ItemStack, T> factory) {
partModels.registerModels(PartModelsHelper.createModels(partClass));
return registry.item(id, props -> new PartItem<>(props, factory)).itemGroup(CreativeTab.INSTANCE)
.rendering(new PartItemRendering()).build();
}
private <T extends IPart> AEColoredItemDefinition constructColoredDefinition(FeatureFactory registry,
String idSuffix, Function<ItemStack, T> factory) {
private <T extends IPart> AEColoredItemDefinition constructColoredDefinition(String idSuffix, Class<T> partClass,
Function<ItemStack, T> factory) {
partModels.registerModels(PartModelsHelper.createModels(partClass));
final ColoredItemDefinition definition = new ColoredItemDefinition();
for (final AEColor color : AEColor.values()) {
@@ -1,159 +0,0 @@
package appeng.core.api.definitions;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.util.ResourceLocation;
import appeng.api.features.AEFeature;
import appeng.api.parts.IPart;
import appeng.fluids.parts.*;
import appeng.items.parts.PartModelsHelper;
import appeng.parts.automation.*;
import appeng.parts.misc.*;
import appeng.parts.networking.*;
import appeng.parts.p2p.*;
import appeng.parts.reporting.*;
enum PartType {
INVALID_TYPE(EnumSet.of(AEFeature.CORE), null),
CABLE_GLASS(EnumSet.of(AEFeature.GLASS_CABLES), GlassCablePart.class) {
@Override
public boolean isCable() {
return true;
}
},
CABLE_COVERED(EnumSet.of(AEFeature.COVERED_CABLES), CoveredCablePart.class) {
@Override
public boolean isCable() {
return true;
}
},
CABLE_SMART(EnumSet.of(AEFeature.CHANNELS, AEFeature.SMART_CABLES), SmartCablePart.class) {
@Override
public boolean isCable() {
return true;
}
},
CABLE_DENSE_SMART(EnumSet.of(AEFeature.CHANNELS, AEFeature.DENSE_CABLES), SmartDenseCablePart.class) {
@Override
public boolean isCable() {
return true;
}
},
CABLE_DENSE_COVERED(EnumSet.of(AEFeature.CHANNELS, AEFeature.DENSE_CABLES), CoveredDenseCablePart.class) {
@Override
public boolean isCable() {
return true;
}
},
TOGGLE_BUS(EnumSet.of(AEFeature.TOGGLE_BUS), ToggleBusPart.class),
INVERTED_TOGGLE_BUS(EnumSet.of(AEFeature.TOGGLE_BUS), InvertedToggleBusPart.class),
CABLE_ANCHOR(EnumSet.of(AEFeature.CABLE_ANCHOR), CableAnchorPart.class),
QUARTZ_FIBER(EnumSet.of(AEFeature.QUARTZ_FIBER), QuartzFiberPart.class),
MONITOR(EnumSet.of(AEFeature.PANELS), PanelPart.class),
SEMI_DARK_MONITOR(EnumSet.of(AEFeature.PANELS), SemiDarkPanelPart.class),
DARK_MONITOR(EnumSet.of(AEFeature.PANELS), DarkPanelPart.class),
STORAGE_BUS(EnumSet.of(AEFeature.STORAGE_BUS), StorageBusPart.class),
FLUID_STORAGE_BUS(EnumSet.of(AEFeature.FLUID_STORAGE_BUS), FluidStorageBusPart.class),
IMPORT_BUS(EnumSet.of(AEFeature.IMPORT_BUS), ImportBusPart.class),
FLUID_IMPORT_BUS(EnumSet.of(AEFeature.FLUID_IMPORT_BUS), FluidImportBusPart.class),
EXPORT_BUS(EnumSet.of(AEFeature.EXPORT_BUS), ExportBusPart.class),
FLUID_EXPORT_BUS(EnumSet.of(AEFeature.FLUID_EXPORT_BUS), FluidExportBusPart.class),
LEVEL_EMITTER(EnumSet.of(AEFeature.LEVEL_EMITTER), LevelEmitterPart.class),
FLUID_LEVEL_EMITTER(EnumSet.of(AEFeature.FLUID_LEVEL_EMITTER), FluidLevelEmitterPart.class),
ANNIHILATION_PLANE(EnumSet.of(AEFeature.ANNIHILATION_PLANE), AnnihilationPlanePart.class),
IDENTITY_ANNIHILATION_PLANE(EnumSet.of(AEFeature.ANNIHILATION_PLANE, AEFeature.IDENTITY_ANNIHILATION_PLANE),
IdentityAnnihilationPlanePart.class),
FLUID_ANNIHILATION_PLANE(EnumSet.of(AEFeature.FLUID_ANNIHILATION_PLANE), FluidAnnihilationPlanePart.class),
FORMATION_PLANE(EnumSet.of(AEFeature.FORMATION_PLANE), FormationPlanePart.class),
FLUID_FORMATION_PLANE(EnumSet.of(AEFeature.FLUID_FORMATION_PLANE), FluidFormationPlanePart.class),
PATTERN_TERMINAL(EnumSet.of(AEFeature.PATTERNS), PatternTerminalPart.class),
CRAFTING_TERMINAL(EnumSet.of(AEFeature.CRAFTING_TERMINAL), CraftingTerminalPart.class),
TERMINAL(EnumSet.of(AEFeature.TERMINAL), TerminalPart.class),
STORAGE_MONITOR(EnumSet.of(AEFeature.STORAGE_MONITOR), StorageMonitorPart.class),
CONVERSION_MONITOR(EnumSet.of(AEFeature.PART_CONVERSION_MONITOR), ConversionMonitorPart.class),
INTERFACE(EnumSet.of(AEFeature.INTERFACE), InterfacePart.class),
FLUID_INTERFACE(EnumSet.of(AEFeature.FLUID_INTERFACE), FluidInterfacePart.class),
P2P_TUNNEL_ME(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_ME), MEP2PTunnelPart.class),
P2P_TUNNEL_REDSTONE(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_REDSTONE), RedstoneP2PTunnelPart.class),
P2P_TUNNEL_ITEM(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_ITEMS), ItemP2PTunnelPart.class),
P2P_TUNNEL_FLUID(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_FLUIDS), FluidP2PTunnelPart.class),
//FIXME P2P_TUNNEL_IC2( 465, "p2p_tunnel_ic2", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_EU ), EnumSet
//FIXME .of( IntegrationType.IC2 ), PartP2PIC2Power.class ),
P2P_TUNNEL_LIGHT(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_LIGHT), LightP2PTunnelPart.class),
P2P_TUNNEL_FE(EnumSet.of(AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_FE), FEP2PTunnelPart.class),
// P2PTunnelOpenComputers( 468, EnumSet.of( AEFeature.P2PTunnel,
// AEFeature.P2PTunnelOpenComputers ), EnumSet.of(
// IntegrationType.OpenComputers ), PartP2POpenComputers.class, GuiText.OCTunnel
// ),
INTERFACE_TERMINAL(EnumSet.of(AEFeature.INTERFACE_TERMINAL), InterfaceTerminalPart.class),
FLUID_TERMINAL(EnumSet.of(AEFeature.FLUID_TERMINAL), FluidTerminalPart.class);
private final Set<AEFeature> features;
private final Set<ResourceLocation> models;
PartType(final Set<AEFeature> features, final Class<? extends IPart> c) {
this.features = Collections.unmodifiableSet(features);
if (c != null) {
this.models = new HashSet<>(PartModelsHelper.createModels(c));
} else {
this.models = Collections.emptySet();
}
}
public boolean isCable() {
return false;
}
public Set<AEFeature> getFeature() {
return this.features;
}
public Set<ResourceLocation> getModels() {
return this.models;
}
}