Skip to content

Commit

Permalink
apply spotless
Browse files Browse the repository at this point in the history
too lazy to rebase
  • Loading branch information
firenoo authored and Dream-Master committed May 1, 2023
1 parent 1fd5b9d commit eba0021
Show file tree
Hide file tree
Showing 21 changed files with 186 additions and 127 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/glodblock/github/FluidCraft.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.glodblock.github;

import com.glodblock.github.crossmod.extracells.EC2Replacer;
import net.minecraft.util.ResourceLocation;

import appeng.api.AEApi;

import com.glodblock.github.common.Config;
import com.glodblock.github.common.storage.FluidCellHandler;
import com.glodblock.github.crossmod.extracells.EC2Replacer;
import com.glodblock.github.crossmod.opencomputers.OCDriverInit;
import com.glodblock.github.crossmod.waila.WailaInit;
import com.glodblock.github.inventory.InventoryHandler;
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/com/glodblock/github/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class Config {
public static int packetSize;
public static int packetRate;
public static boolean replaceEC2;

public static void run() {
loadCategory();
loadProperty();
Expand Down Expand Up @@ -60,8 +61,11 @@ private static void loadProperty() {
.get("Fluid Craft for AE2", "packetRate", 50, "Period at which packets are dispatched, in ms.")
.getInt();
if (packetRate <= 0) packetRate = 50;
replaceEC2 = Config.getBoolean("Fluid Craft for AE2", "replaceEC2", true,
"Set true to handle missing item mappings from EC2. Note to work properly, you must have all relevant parts.");
replaceEC2 = Config.getBoolean(
"Fluid Craft for AE2",
"replaceEC2",
true,
"Set true to handle missing item mappings from EC2. Note to work properly, you must have all relevant parts.");
if (Config.hasChanged()) Config.save();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import java.util.ArrayList;
import java.util.List;

import com.glodblock.github.crossmod.extracells.storage.ProxyFluidCellInventory;
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidStorageCell;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
Expand All @@ -25,6 +23,8 @@
import appeng.util.item.AEFluidStack;

import com.glodblock.github.common.item.ItemCreativeFluidStorageCell;
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidCellInventory;
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidStorageCell;

public class FluidCellInventory implements IFluidCellInventory {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package com.glodblock.github.crossmod.extracells;

import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import java.util.List;

import net.minecraft.item.Item;

import java.util.List;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.registry.GameRegistry;

public class EC2Replacer {


/**
* Should be called if and only if replaceEC2 config is true and EC2 not present. Registers proxy
* items for the entire EC2 mod. After running this once, you should set replaceEC2 back to false.
* Should be called if and only if replaceEC2 config is true and EC2 not present. Registers proxy items for the
* entire EC2 mod. After running this once, you should set replaceEC2 back to false.
*/
public static void initReplacer() {
ItemReplacements.init();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package com.glodblock.github.crossmod.extracells;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;

import net.minecraft.item.Item;

import appeng.api.AEApi;
import appeng.api.definitions.IItemDefinition;

import com.glodblock.github.common.item.ItemMultiFluidStorageCell;
import com.glodblock.github.crossmod.extracells.parts.*;
import com.glodblock.github.crossmod.extracells.storage.*;
import com.glodblock.github.loader.ItemAndBlockHolder;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.item.Item;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;

/**
* Shell class to organize proxy replacements and hide the ugliness
Expand All @@ -26,26 +28,19 @@ static void init() {
ItemReplacements.proxyItems();
ItemReplacements.proxyPartItems();
}

/**
* Register proxy items (non-parts)
*/
static void proxyItems() {
deprecateFluidStorage("storage.fluid", 0, ItemAndBlockHolder.CELL1KM,
1, 8, 0.5);
deprecateFluidStorage("storage.fluid", 1, ItemAndBlockHolder.CELL4KM,
4, 32, 1.0);
deprecateFluidStorage("storage.fluid", 2, ItemAndBlockHolder.CELL16KM,
16, 128, 1.5);
deprecateFluidStorage("storage.fluid", 3, ItemAndBlockHolder.CELL64KM,
64, 512, 2.0);
deprecateFluidStorage("storage.fluid", 4, ItemAndBlockHolder.CELL256KM,
256, 2048, 2.5);
deprecateFluidStorage("storage.fluid", 5, ItemAndBlockHolder.CELL1024KM,
1024, 8192, 3.0);
deprecateFluidStorage("storage.fluid", 6, ItemAndBlockHolder.CELL4096KM,
4096, 32768, 3.5);
deprecateFluidStorage("storage.fluid", 7, ItemAndBlockHolder.CELL16384KM,
16384, 131072, 4.0);
deprecateFluidStorage("storage.fluid", 0, ItemAndBlockHolder.CELL1KM, 1, 8, 0.5);
deprecateFluidStorage("storage.fluid", 1, ItemAndBlockHolder.CELL4KM, 4, 32, 1.0);
deprecateFluidStorage("storage.fluid", 2, ItemAndBlockHolder.CELL16KM, 16, 128, 1.5);
deprecateFluidStorage("storage.fluid", 3, ItemAndBlockHolder.CELL64KM, 64, 512, 2.0);
deprecateFluidStorage("storage.fluid", 4, ItemAndBlockHolder.CELL256KM, 256, 2048, 2.5);
deprecateFluidStorage("storage.fluid", 5, ItemAndBlockHolder.CELL1024KM, 1024, 8192, 3.0);
deprecateFluidStorage("storage.fluid", 6, ItemAndBlockHolder.CELL4096KM, 4096, 32768, 3.5);
deprecateFluidStorage("storage.fluid", 7, ItemAndBlockHolder.CELL16384KM, 16384, 131072, 4.0);
// Thanks, AEApi.
AEApi.instance().registries().cell().addCellHandler(new ProxyItemCellHandler());
AEApi.instance().registries().cell().addCellHandler(new ProxyVoidCellHandler());
Expand All @@ -54,19 +49,28 @@ static void proxyItems() {
deprecateItemStorage(2, AEApi.instance().definitions().items().cell4096k(), 4096, 32768, 3.5);
deprecateItemStorage(3, AEApi.instance().definitions().items().cell16384k(), 16384, 131072, 4.0);
deprecateItemStorage(4, AEApi.instance().definitions().items().cellContainer(), 65536, 8, 2.0, 1);
deprecateExtremeStorage("storage.physical.advanced.quantum", 0,
AEApi.instance().definitions().items().cellQuantum(), Integer.MAX_VALUE / 16, 4096, 1000.0);
deprecateExtremeStorage("storage.physical.advanced.singularity", 0,
AEApi.instance().definitions().items().cellSingularity(), Long.MAX_VALUE / 16, 4096, 15000.0);
//Deprecate void cell manually
deprecateExtremeStorage(
"storage.physical.advanced.quantum",
0,
AEApi.instance().definitions().items().cellQuantum(),
Integer.MAX_VALUE / 16,
4096,
1000.0);
deprecateExtremeStorage(
"storage.physical.advanced.singularity",
0,
AEApi.instance().definitions().items().cellSingularity(),
Long.MAX_VALUE / 16,
4096,
15000.0);
// Deprecate void cell manually
ProxyVoidStorageCell voidCell = new ProxyVoidStorageCell();
GameRegistry.registerItem(voidCell, "ec2placeholder.storage.physical.void");
registry.put("extracells:storage.physical.void", voidCell);
deprecateItem("pattern.fluid", ItemAndBlockHolder.PATTERN);
deprecateItem("terminal.fluid.wireless", ItemAndBlockHolder.WIRELESS_FLUID_TERM);
/* Storage casings */
deprecateItem("storage.casing", 0,
AEApi.instance().definitions().materials().emptyAdvancedStorageCell());
deprecateItem("storage.casing", 0, AEApi.instance().definitions().materials().emptyAdvancedStorageCell());
deprecateItem("storage.casing", 1, ItemAndBlockHolder.CELL_HOUSING, 2);
/* Storage components (1k component, etc.) */
deprecateItem("storage.component", 0, AEApi.instance().definitions().materials().cell256kPart());
Expand Down Expand Up @@ -143,10 +147,11 @@ private static ProxyExtremeStorageCell getOrBuildItemStorage(String srcName) {

/**
* Deprecate a simple item.
* @param srcName name of the to-be-replaced item without the mod id prefix
* @param srcMeta meta of the to-be-replaced item
*
* @param srcName name of the to-be-replaced item without the mod id prefix
* @param srcMeta meta of the to-be-replaced item
* @param replacement item that will replace src
* @param targetMeta meta of the item that will replace src
* @param targetMeta meta of the item that will replace src
*/
private static void deprecateItem(String srcName, int srcMeta, Item replacement, int targetMeta) {
getOrBuildItem(srcName).addMetaReplacement(srcMeta, replacement, targetMeta);
Expand All @@ -162,13 +167,16 @@ private static void deprecateItem(String srcName, Item replacement) {

private static void deprecateItem(String srcName, int srcMeta, IItemDefinition replacement) {
if (replacement.isEnabled()) {
deprecateItem(srcName, srcMeta,
replacement.maybeItem().get(),
replacement.maybeStack(1).get().getItemDamage());
deprecateItem(
srcName,
srcMeta,
replacement.maybeItem().get(),
replacement.maybeStack(1).get().getItemDamage());
}
}

private static void deprecateItemPart(int srcMeta, Item replacement, Function<ProxyPartItem, ProxyPart> partBuilder) {
private static void deprecateItemPart(int srcMeta, Item replacement,
Function<ProxyPartItem, ProxyPart> partBuilder) {
final String fullName = "extracells:part.base";
ProxyPartItem proxyItem = (ProxyPartItem) registry.get(fullName);
if (proxyItem == null) {
Expand All @@ -182,51 +190,65 @@ private static void deprecateItemPart(int srcMeta, Item replacement, Function<Pr
/**
* Deprecate a fluid storage item. Note that we can't access the properties directly, so we need to do this
*/
private static void deprecateFluidStorage(String srcName, int srcMeta, ItemMultiFluidStorageCell replacement, long kilobytes, int bytesPerType, double idleDrain) {
private static void deprecateFluidStorage(String srcName, int srcMeta, ItemMultiFluidStorageCell replacement,
long kilobytes, int bytesPerType, double idleDrain) {
ProxyFluidStorageCell proxyItem = getOrBuildFluidStorage(srcName);
ProxyItem.ProxyStorageEntry entry = new ProxyItem.ProxyStorageEntry(replacement, kilobytes, bytesPerType, idleDrain);
ProxyItem.ProxyStorageEntry entry = new ProxyItem.ProxyStorageEntry(
replacement,
kilobytes,
bytesPerType,
idleDrain);
proxyItem.addMetaReplacement(srcMeta, entry);
}

/**
* Deprecate a storage item. This goes through AEAPI, as AE2FC doesn't have any item cells.
* If the item is disabled in AEAPI, the replacement will not be registered!
* Deprecate a storage item. This goes through AEAPI, as AE2FC doesn't have any item cells. If the item is disabled
* in AEAPI, the replacement will not be registered!
*/
private static void deprecateItemStorage(int srcMeta, IItemDefinition replacement, long kilobytes, int bytesPerType, double idleDrain) {
private static void deprecateItemStorage(int srcMeta, IItemDefinition replacement, long kilobytes, int bytesPerType,
double idleDrain) {
if (replacement.isEnabled()) {
ProxyItemStorageCell item = getOrBuildItemStorage();
int meta = replacement.maybeStack(1).get().getItemDamage();
ProxyItem.ProxyItemEntry storage = new ProxyItem.ProxyStorageEntry(
replacement.maybeItem().get(), kilobytes, bytesPerType, idleDrain);
replacement.maybeItem().get(),
kilobytes,
bytesPerType,
idleDrain);
item.addMetaReplacement(srcMeta, storage);
}
}

/**
* Deprecate a storage item. This goes through AEAPI, as AE2FC doesn't have any item cells.
* If the item is disabled in AEAPI, the replacement will not be registered!
* Deprecate a storage item. This goes through AEAPI, as AE2FC doesn't have any item cells. If the item is disabled
* in AEAPI, the replacement will not be registered!
*/
private static void deprecateItemStorage(int srcMeta, IItemDefinition replacement, long kilobytes, int bytesPerType, double idleDrain, int types) {
private static void deprecateItemStorage(int srcMeta, IItemDefinition replacement, long kilobytes, int bytesPerType,
double idleDrain, int types) {
if (replacement.isEnabled()) {
ProxyItemStorageCell item = getOrBuildItemStorage();
int meta = replacement.maybeStack(1).get().getItemDamage();
ProxyItem.ProxyItemEntry storage = new ProxyItem.ProxyStorageEntry(
replacement.maybeItem().get(), kilobytes, bytesPerType, idleDrain, types);
replacement.maybeItem().get(),
kilobytes,
bytesPerType,
idleDrain,
types);
item.addMetaReplacement(srcMeta, storage);
}
}

private static void deprecateExtremeStorage(String srcName, int srcMeta, IItemDefinition replacement, long bytes, int bytesPerType, double idleDrain) {
private static void deprecateExtremeStorage(String srcName, int srcMeta, IItemDefinition replacement, long bytes,
int bytesPerType, double idleDrain) {
if (replacement.isEnabled()) {
ProxyExtremeStorageCell item = getOrBuildItemStorage(srcName);
int meta = replacement.maybeStack(1).get().getItemDamage();
ProxyItem.ProxyItemEntry storage = new ProxyItem.ProxyStorageEntry(
replacement.maybeItem().get(), bytes / 1024, bytesPerType, idleDrain);
replacement.maybeItem().get(),
bytes / 1024,
bytesPerType,
idleDrain);
item.addMetaReplacement(srcMeta, storage);
}
}
}




Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.glodblock.github.crossmod.extracells;

import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.FCBaseItem;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.client.resources.I18n;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
Expand All @@ -12,9 +12,9 @@
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.FCBaseItem;
import cpw.mods.fml.common.registry.GameRegistry;

/**
* EC2ProxyItem - Item that "holds" the data of a missing item.
Expand All @@ -27,6 +27,7 @@ public class ProxyItem extends FCBaseItem {
* Maps a metadata value to a replacement.
*/
protected final Map<Integer, ProxyItemEntry> replacements;

public ProxyItem(String ec2itemName) {
this.name = ec2itemName;
this.replacements = new HashMap<>();
Expand Down Expand Up @@ -90,9 +91,8 @@ public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int p_7766
}

/**
* Base class for a mapping from source (Item, meta) -> replacement (Item, meta).
* Optionally, override the {@link ProxyItemEntry#replaceNBT(NBTTagCompound)}
* method for custom NBT migration.
* Base class for a mapping from source (Item, meta) -> replacement (Item, meta). Optionally, override the
* {@link ProxyItemEntry#replaceNBT(NBTTagCompound)} method for custom NBT migration.
*/
protected static class ProxyItemEntry {

Expand All @@ -101,7 +101,8 @@ protected static class ProxyItemEntry {

/**
* Creates a Proxy Replacement.
* @param replacement Item that will replace the other.
*
* @param replacement Item that will replace the other.
* @param replacementMeta Metadata/damage value of the replacement
*/
protected ProxyItemEntry(Item replacement, int replacementMeta) {
Expand All @@ -116,10 +117,12 @@ NBTTagCompound replaceNBT(NBTTagCompound compound) {
}

protected static class ProxyStorageEntry extends ProxyItemEntry {

public final long maxBytes;
public final int bytesPerType;
public final double idleDrain;
public final int types;

protected ProxyStorageEntry(Item replacement, long kilobytes, int bytesPerType, double idleDrain) {
super(replacement, 0);
this.maxBytes = kilobytes * 1024;
Expand All @@ -135,6 +138,7 @@ protected ProxyStorageEntry(Item replacement, long kilobytes, int bytesPerType,
this.idleDrain = idleDrain;
this.types = types;
}

@Override
NBTTagCompound replaceNBT(NBTTagCompound compound) {
if (compound != null && compound.hasKey("ecc")) {
Expand Down
Loading

0 comments on commit eba0021

Please sign in to comment.