Skip to content

Commit

Permalink
Merge branch 'master' into feature/nei-recipe-modify
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss authored Jan 13, 2025
2 parents 3bb7c66 + 3abcd04 commit e0acc9f
Show file tree
Hide file tree
Showing 16 changed files with 120 additions and 152 deletions.
11 changes: 4 additions & 7 deletions src/main/java/bartworks/common/items/ItemCircuitProgrammer.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import bartworks.util.BWUtil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.GregTechAPI;
import gregtech.api.enums.GTValues;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
Expand All @@ -63,12 +62,10 @@ public ItemCircuitProgrammer() {
this.setNoRepair();
this.setHasSubtypes(false);
this.setCreativeTab(MainMod.BWT);
GregTechAPI.registerCircuitProgrammer(
s -> s.getItem() instanceof ItemCircuitProgrammer && ElectricItem.manager.canUse(s, COST_PER_USE),
(s, p) -> {
ElectricItem.manager.use(s, COST_PER_USE, p);
return s;
});
}

public void useItem(ItemStack stack, EntityPlayer player) {
ElectricItem.manager.use(stack, COST_PER_USE, player);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected MultiblockTooltipBuilder createTooltip() {
.addOutputHatch("1-16, Hint block with dot 1", 1)
.addStructureInfo("Supports Crafting Input Buffer")
.addStructureInfo(
"ALL Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) hatchTier())
"Energy Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) energyHatchTier())
+ EnumChatFormatting.GRAY
+ " or better")
.toolTipFinisher();
Expand Down Expand Up @@ -120,7 +120,7 @@ public int getGlassMeta() {
}

@Override
public int hatchTier() {
public int energyHatchTier() {
return 6;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected MultiblockTooltipBuilder createTooltip() {
.addOutputHatch("1-16, Hint block with dot 1", 1)
.addStructureInfo("Supports Crafting Input Buffer")
.addStructureInfo(
"ALL Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) hatchTier())
"Energy Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) energyHatchTier())
+ EnumChatFormatting.GRAY
+ " or better")
.toolTipFinisher();
Expand Down Expand Up @@ -121,7 +121,7 @@ public int getGlassMeta() {
}

@Override
public int hatchTier() {
public int energyHatchTier() {
return 7;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected MultiblockTooltipBuilder createTooltip() {
.addOutputHatch("1-16, Hint block with dot 1", 1)
.addStructureInfo("Supports Crafting Input Buffer")
.addStructureInfo(
"ALL Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) hatchTier())
"Energy Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) energyHatchTier())
+ EnumChatFormatting.GRAY
+ " or better")
.toolTipFinisher();
Expand Down Expand Up @@ -122,7 +122,7 @@ public int getGlassMeta() {
}

@Override
public int hatchTier() {
public int energyHatchTier() {
return 8;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected MultiblockTooltipBuilder createTooltip() {
.addOutputHatch("1-16, Hint block with dot 1", 1)
.addStructureInfo("Supports Crafting Input Buffer")
.addStructureInfo(
"ALL Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) hatchTier())
"Energy Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) energyHatchTier())
+ EnumChatFormatting.GRAY
+ " or better")
.toolTipFinisher();
Expand Down Expand Up @@ -121,7 +121,7 @@ public int getGlassMeta() {
}

@Override
public int hatchTier() {
public int energyHatchTier() {
return 9;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected MultiblockTooltipBuilder createTooltip() {
.addOutputHatch("1-16, Hint block with dot 1", 1)
.addStructureInfo("Supports Crafting Input Buffer")
.addStructureInfo(
"ALL Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) hatchTier())
"Energy Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) energyHatchTier())
+ EnumChatFormatting.GRAY
+ " or better")
.toolTipFinisher();
Expand Down Expand Up @@ -122,7 +122,7 @@ public int getGlassMeta() {
}

@Override
public int hatchTier() {
public int energyHatchTier() {
return 10;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,8 @@ protected IStructureDefinition<MTELargeFusionComputer> computeValue(Class<?> typ
.atLeast(
gregtech.api.enums.HatchElement.InputHatch.or(gregtech.api.enums.HatchElement.InputBus),
gregtech.api.enums.HatchElement.OutputHatch)
.adder(MTELargeFusionComputer::addFluidIO)
.casingIndex(x.textureIndex())
.dot(1)
.hatchItemFilterAnd(x2 -> filterByMTETier(x2.hatchTier(), Integer.MAX_VALUE))
.buildAndChain(x.getGlassBlock(), x.getGlassMeta())))
.addElement(
'E',
Expand All @@ -119,7 +117,7 @@ protected IStructureDefinition<MTELargeFusionComputer> computeValue(Class<?> typ
.or(gregtech.api.enums.HatchElement.Energy))
.adder(MTELargeFusionComputer::addEnergyInjector)
.casingIndex(x.textureIndex())
.hatchItemFilterAnd(x2 -> filterByMTETier(x2.hatchTier(), Integer.MAX_VALUE))
.hatchItemFilterAnd(x2 -> filterByMTETier(x2.energyHatchTier(), Integer.MAX_VALUE))
.dot(2)
.buildAndChain(x.getCasingBlock(), x.getCasingMeta())))
.addElement('F', lazy(x -> ofFrame(x.getFrameBox())))
Expand Down Expand Up @@ -197,7 +195,7 @@ public long maxEUStore() {

public abstract int getGlassMeta();

public abstract int hatchTier();
public abstract int energyHatchTier();

public abstract Materials getFrameBox();

Expand Down Expand Up @@ -485,40 +483,17 @@ private boolean addEnergyInjector(IGregTechTileEntity aBaseMetaTileEntity, int a
IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity();
if (aMetaTileEntity == null) return false;
if (aMetaTileEntity instanceof MTEHatchEnergy tHatch) {
if (tHatch.getTierForStructure() < hatchTier()) return false;
if (tHatch.getTierForStructure() < energyHatchTier()) return false;
tHatch.updateTexture(aBaseCasingIndex);
return mEnergyHatches.add(tHatch);
} else if (aMetaTileEntity instanceof MTEHatchEnergyMulti tHatch) {
if (tHatch.getTierForStructure() < hatchTier()) return false;
if (tHatch.getTierForStructure() < energyHatchTier()) return false;
tHatch.updateTexture(aBaseCasingIndex);
return eEnergyMulti.add(tHatch);
}
return false;
}

private boolean addFluidIO(IGregTechTileEntity aBaseMetaTileEntity, int aBaseCasingIndex) {
IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity();
if (aMetaTileEntity == null) return false;
if (aMetaTileEntity instanceof MTEHatch hatch) {
hatch.updateTexture(aBaseCasingIndex);
hatch.updateCraftingIcon(this.getMachineCraftingIcon());
}
if (aMetaTileEntity instanceof MTEHatchInput tInput) {
if (tInput.getTierForStructure() < hatchTier()) return false;
tInput.mRecipeMap = getRecipeMap();
return mInputHatches.add(tInput);
}
if (aMetaTileEntity instanceof MTEHatchOutput tOutput) {
if (tOutput.getTierForStructure() < hatchTier()) return false;
return mOutputHatches.add(tOutput);
}
if (aMetaTileEntity instanceof IDualInputHatch tInput) {
tInput.updateCraftingIcon(this.getMachineCraftingIcon());
return mDualInputHatches.add(tInput);
}
return false;
}

private boolean addDroneHatch(IGregTechTileEntity aBaseMetaTileEntity, int aBaseCasingIndex) {
if (aBaseMetaTileEntity == null) return false;
IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity();
Expand Down
14 changes: 0 additions & 14 deletions src/main/java/gregtech/GTMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static gregtech.GT_Version.VERSION_MAJOR;
import static gregtech.GT_Version.VERSION_MINOR;
import static gregtech.GT_Version.VERSION_PATCH;
import static gregtech.api.GregTechAPI.registerCircuitProgrammer;
import static gregtech.api.enums.Mods.Forestry;
import static gregtech.api.util.GTRecipe.setItemStacks;

Expand All @@ -13,7 +12,6 @@
import java.util.Arrays;
import java.util.Locale;
import java.util.Map;
import java.util.function.Predicate;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
Expand All @@ -26,7 +24,6 @@
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraft.world.World;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.oredict.OreDictionary;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -354,17 +351,6 @@ public void onLoad(FMLInitializationEvent aEvent) {

gregtechproxy.onLoad();

registerCircuitProgrammer(new Predicate<>() {

private final int screwdriverOreId = OreDictionary.getOreID("craftingToolScrewdriver");

@Override
public boolean test(ItemStack stack) {
for (int i : OreDictionary.getOreIDs(stack)) if (i == screwdriverOreId) return true;
return false;
}
}, true);

new MTERecipeLoader().run();

new GTItemIterator().run();
Expand Down
23 changes: 0 additions & 23 deletions src/main/java/gregtech/api/GregTechAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,20 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiFunction;
import java.util.function.IntFunction;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import javax.annotation.Nonnull;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
Expand Down Expand Up @@ -163,9 +159,6 @@ public class GregTechAPI {
private static final Multimap<Integer, ItemStack> sRealConfigurationList = Multimaps
.newListMultimap(new TreeMap<>(), ArrayList::new);
private static final Map<Integer, List<ItemStack>> sConfigurationLists = new ConcurrentHashMap<>();
private static final Map<Predicate<ItemStack>, BiFunction<ItemStack, EntityPlayerMP, ItemStack>> sRealCircuitProgrammerList = new LinkedHashMap<>();
public static final Map<Predicate<ItemStack>, BiFunction<ItemStack, EntityPlayerMP, ItemStack>> sCircuitProgrammerList = Collections
.unmodifiableMap(sRealCircuitProgrammerList);

/**
* The List of Dimensions, which are Whitelisted for the Teleporter. This list should not contain other Planets.
Expand Down Expand Up @@ -449,22 +442,6 @@ public static Comparator<ItemStack> getConfigurationCircuitsComparator() {
.thenComparing(ItemStack::getItemDamage);
}

public static void registerCircuitProgrammer(ItemStack stack, boolean ignoreNBT, boolean useContainer) {
registerCircuitProgrammer(rhs -> GTUtility.areStacksEqual(stack, rhs, ignoreNBT), useContainer);
}

public static void registerCircuitProgrammer(Predicate<ItemStack> predicate, boolean useContainer) {
sRealCircuitProgrammerList.put(
predicate,
useContainer ? (s, p) -> s.getItem()
.getContainerItem(s) : (s, p) -> s);
}

public static void registerCircuitProgrammer(Predicate<ItemStack> predicate,
BiFunction<ItemStack, EntityPlayerMP, ItemStack> doDamage) {
sRealCircuitProgrammerList.put(predicate, doDamage);
}

public static void registerCover(ItemStack aStack, ITexture aCover, CoverBehavior aBehavior) {
registerCover(aStack, aCover, (CoverBehaviorBase<?>) aBehavior);
}
Expand Down
Loading

0 comments on commit e0acc9f

Please sign in to comment.