Skip to content

Commit

Permalink
Merge branch 'GregTechCEu:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
marisathewitch authored Jan 14, 2024
2 parents 231a053 + 3e0835e commit 5b91635
Show file tree
Hide file tree
Showing 47 changed files with 441 additions and 215 deletions.
10 changes: 8 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1704659416
//version: 1705076830
/*
* DO NOT CHANGE THIS FILE!
* Also, you may replace this file at any time if there is an update available.
Expand All @@ -24,7 +24,7 @@ plugins {
id 'eclipse'
id 'maven-publish'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7'
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.25'
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.28'
id 'net.darkhax.curseforgegradle' version '1.1.17' apply false
id 'com.modrinth.minotaur' version '2.8.6' apply false
id 'com.diffplug.spotless' version '6.13.0' apply false
Expand Down Expand Up @@ -541,6 +541,12 @@ pluginManager.withPlugin('org.jetbrains.kotlin.kapt') {
}
}

configurations.configureEach {
resolutionStrategy.dependencySubstitution {
substitute module('org.scala-lang:scala-library:2.11.1') using module('org.scala-lang:scala-library:2.11.5') because('To allow mixing with Java 8 targets')
}
}

if (getFile('dependencies.gradle').exists()) {
apply from: 'dependencies.gradle'
} else if (getFile('dependencies.gradle.kts').exists()) {
Expand Down
26 changes: 0 additions & 26 deletions src/main/java/gregtech/api/GregTechAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,14 @@
import gregtech.api.modules.IModuleManager;
import gregtech.api.network.INetworkHandler;
import gregtech.api.sound.ISoundManager;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.Material;
import gregtech.api.unification.material.Materials;
import gregtech.api.unification.material.registry.IMaterialRegistryManager;
import gregtech.api.unification.material.registry.MarkerMaterialRegistry;
import gregtech.api.unification.ore.OrePrefix;
import gregtech.api.unification.ore.StoneType;
import gregtech.api.util.BaseCreativeTab;
import gregtech.api.util.GTControlledRegistry;
import gregtech.api.util.GTLog;
import gregtech.api.util.IBlockOre;
import gregtech.common.ConfigHolder;
import gregtech.common.blocks.BlockWarningSign;
import gregtech.common.blocks.MetaBlocks;
import gregtech.common.items.MetaItems;
import gregtech.common.items.ToolItems;
import gregtech.common.metatileentities.MetaTileEntities;

import net.minecraft.block.state.IBlockState;
import net.minecraft.util.ResourceLocation;
Expand Down Expand Up @@ -78,23 +69,6 @@ public class GregTechAPI {
public static final Object2ObjectMap<IBlockState, IHeatingCoilBlockStats> HEATING_COILS = new Object2ObjectOpenHashMap<>();
public static final Object2ObjectMap<IBlockState, IBatteryData> PSS_BATTERIES = new Object2ObjectOpenHashMap<>();

public static final BaseCreativeTab TAB_GREGTECH = new BaseCreativeTab(GTValues.MODID + ".main",
() -> MetaItems.LOGO.getStackForm(), true);
public static final BaseCreativeTab TAB_GREGTECH_MACHINES = new BaseCreativeTab(GTValues.MODID + ".machines",
() -> MetaTileEntities.ELECTRIC_BLAST_FURNACE.getStackForm(), true);
public static final BaseCreativeTab TAB_GREGTECH_CABLES = new BaseCreativeTab(GTValues.MODID + ".cables",
() -> OreDictUnifier.get(OrePrefix.cableGtDouble, Materials.Aluminium), true);
public static final BaseCreativeTab TAB_GREGTECH_PIPES = new BaseCreativeTab(GTValues.MODID + ".pipes",
() -> OreDictUnifier.get(OrePrefix.pipeNormalFluid, Materials.Aluminium), true);
public static final BaseCreativeTab TAB_GREGTECH_TOOLS = new BaseCreativeTab(GTValues.MODID + ".tools",
() -> ToolItems.HARD_HAMMER.get(Materials.Aluminium), true);
public static final BaseCreativeTab TAB_GREGTECH_MATERIALS = new BaseCreativeTab(GTValues.MODID + ".materials",
() -> OreDictUnifier.get(OrePrefix.ingot, Materials.Aluminium), true);
public static final BaseCreativeTab TAB_GREGTECH_ORES = new BaseCreativeTab(GTValues.MODID + ".ores",
() -> OreDictUnifier.get(OrePrefix.ore, Materials.Aluminium), true);
public static final BaseCreativeTab TAB_GREGTECH_DECORATIONS = new BaseCreativeTab(GTValues.MODID + ".decorations",
() -> MetaBlocks.WARNING_SIGN.getItemVariant(BlockWarningSign.SignType.YELLOW_STRIPES), true);

/** Will be available at the Pre-Initialization stage */
public static boolean isHighTier() {
return highTier;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gregtech/api/block/VariantBlock.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gregtech.api.block;

import gregtech.api.GregTechAPI;
import gregtech.api.util.LocalizationUtils;
import gregtech.common.creativetab.GTCreativeTabs;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
Expand Down Expand Up @@ -43,7 +43,7 @@ public VariantBlock(Material materialIn) {
state);
}
}
setCreativeTab(GregTechAPI.TAB_GREGTECH);
setCreativeTab(GTCreativeTabs.TAB_GREGTECH);
setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, VALUES[0]));
}

Expand Down
18 changes: 14 additions & 4 deletions src/main/java/gregtech/api/block/machines/BlockMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import gregtech.api.pipenet.IBlockAppearance;
import gregtech.api.util.GTUtility;
import gregtech.client.renderer.handler.MetaTileEntityRenderer;
import gregtech.common.creativetab.GTCreativeTabs;
import gregtech.common.items.MetaItems;
import gregtech.integration.ctm.IFacadeWrapper;

Expand All @@ -40,7 +41,11 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
Expand All @@ -63,7 +68,12 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.Set;

import static gregtech.api.util.GTUtility.getMetaTileEntity;

Expand All @@ -83,7 +93,7 @@ public class BlockMachine extends BlockCustomParticle implements ITileEntityProv

public BlockMachine() {
super(Material.IRON);
setCreativeTab(GregTechAPI.TAB_GREGTECH_MACHINES);
setCreativeTab(GTCreativeTabs.TAB_GREGTECH_MACHINES);
setSoundType(SoundType.METAL);
setHardness(6.0f);
setResistance(6.0f);
Expand Down Expand Up @@ -423,7 +433,7 @@ public void harvestBlock(@NotNull World worldIn, @NotNull EntityPlayer player, @
@NotNull IBlockState state, @Nullable TileEntity te, @NotNull ItemStack stack) {
tileEntities.set(te == null ? tileEntities.get() : ((IGregTechTileEntity) te).getMetaTileEntity());
super.harvestBlock(worldIn, player, pos, state, te, stack);
tileEntities.set(null);
tileEntities.remove();
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import gregtech.api.util.LocalizationUtils;
import gregtech.client.utils.TooltipHelper;
import gregtech.common.ConfigHolder;
import gregtech.common.creativetab.GTCreativeTabs;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
Expand Down Expand Up @@ -61,8 +62,8 @@ public class MachineItemBlock extends ItemBlock {
*/
public static void addCreativeTab(CreativeTabs creativeTab) {
Preconditions.checkNotNull(creativeTab, "creativeTab");
if (creativeTab == GregTechAPI.TAB_GREGTECH_MACHINES) {
throw new IllegalArgumentException("Adding " + GregTechAPI.TAB_GREGTECH_MACHINES.tabLabel +
if (creativeTab == GTCreativeTabs.TAB_GREGTECH_MACHINES) {
throw new IllegalArgumentException("Adding " + GTCreativeTabs.TAB_GREGTECH_MACHINES.tabLabel +
" as additional creative tab is redundant.");
} else if (creativeTab == CreativeTabs.SEARCH) {
throw new IllegalArgumentException(
Expand Down
63 changes: 53 additions & 10 deletions src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package gregtech.api.capability.impl;

import gregtech.api.GTValues;
import gregtech.api.capability.*;
import gregtech.api.capability.GregtechDataCodes;
import gregtech.api.capability.GregtechTileCapabilities;
import gregtech.api.capability.IMultiblockController;
import gregtech.api.capability.IMultipleTankHandler;
import gregtech.api.capability.IWorkable;
import gregtech.api.metatileentity.MTETrait;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.multiblock.CleanroomType;
Expand Down Expand Up @@ -432,34 +436,53 @@ protected boolean checkCleanroomRequirement(@NotNull Recipe recipe) {
* <ol>
* <li>The recipe is run in parallel if possible.</li>
* <li>The potentially parallel recipe is then checked to exist.</li>
* <li>If it exists, it checks if the recipe is runnable with the current inputs.</li>
* <li>If it exists, it checks if the recipe is runnable with the inputs provided.</li>
* </ol>
* If the above conditions are met, the recipe is engaged to be run
*
* @param recipe the recipe to prepare
* @param recipe the recipe to prepare
* @param inputInventory the inventory to draw items from
* @param inputFluidInventory the fluid tanks to draw fluid from
* @return true if the recipe was successfully prepared, else false
*/
protected boolean prepareRecipe(Recipe recipe) {
public boolean prepareRecipe(Recipe recipe, IItemHandlerModifiable inputInventory,
IMultipleTankHandler inputFluidInventory) {
recipe = Recipe.trimRecipeOutputs(recipe, getRecipeMap(), metaTileEntity.getItemOutputLimit(),
metaTileEntity.getFluidOutputLimit());

// Pass in the trimmed recipe to the parallel logic
recipe = findParallelRecipe(
recipe,
getInputInventory(),
getInputTank(),
inputInventory,
inputFluidInventory,
getOutputInventory(),
getOutputTank(),
getMaxParallelVoltage(),
getParallelLimit());

if (recipe != null && setupAndConsumeRecipeInputs(recipe, getInputInventory())) {
if (recipe != null && setupAndConsumeRecipeInputs(recipe, inputInventory, inputFluidInventory)) {
setupRecipe(recipe);
return true;
}
return false;
}

/**
* Prepares the recipe to be run.
* <ol>
* <li>The recipe is run in parallel if possible.</li>
* <li>The potentially parallel recipe is then checked to exist.</li>
* <li>If it exists, it checks if the recipe is runnable with the current inputs.</li>
* </ol>
* If the above conditions are met, the recipe is engaged to be run
*
* @param recipe the recipe to prepare
* @return true if the recipe was successfully prepared from the default inventory, else false
*/
public boolean prepareRecipe(Recipe recipe) {
return prepareRecipe(recipe, getInputInventory(), getInputTank());
}

/**
* DO NOT use the parallelLimit field directly, EVER
*
Expand Down Expand Up @@ -549,11 +572,14 @@ protected static boolean areItemStacksEqual(@NotNull ItemStack stackA, @NotNull
* @param recipe - The Recipe that will be consumed from the inputs and ran in the machine
* @param importInventory - The inventory that the recipe should be consumed from.
* Used mainly for Distinct bus implementation for multiblocks to specify
* a specific bus
* a specific bus, or for addons to use external inventories.
* @param importFluids - The tanks that the recipe should be consumed from
* Used currently in addons to use external tanks.
* @return - true if the recipe is successful, false if the recipe is not successful
*/
protected boolean setupAndConsumeRecipeInputs(@NotNull Recipe recipe,
@NotNull IItemHandlerModifiable importInventory) {
@NotNull IItemHandlerModifiable importInventory,
@NotNull IMultipleTankHandler importFluids) {
this.overclockResults = calculateOverclock(recipe);

modifyOverclockPost(overclockResults, recipe.getRecipePropertyStorage());
Expand All @@ -563,7 +589,6 @@ protected boolean setupAndConsumeRecipeInputs(@NotNull Recipe recipe,
}

IItemHandlerModifiable exportInventory = getOutputInventory();
IMultipleTankHandler importFluids = getInputTank();
IMultipleTankHandler exportFluids = getOutputTank();

// We have already trimmed outputs and chanced outputs at this time
Expand All @@ -589,6 +614,24 @@ protected boolean setupAndConsumeRecipeInputs(@NotNull Recipe recipe,
return false;
}

/**
* Determines if the provided recipe is possible to run from the provided inventory, or if there is anything
* preventing
* the Recipe from being completed.
* <p>
* Will consume the inputs of the Recipe if it is possible to run.
*
* @param recipe - The Recipe that will be consumed from the inputs and ran in the machine
* @param importInventory - The inventory that the recipe should be consumed from.
* Used mainly for Distinct bus implementation for multiblocks to specify
* a specific bus
* @return - true if the recipe is successful, false if the recipe is not successful
*/
protected boolean setupAndConsumeRecipeInputs(@NotNull Recipe recipe,
@NotNull IItemHandlerModifiable importInventory) {
return setupAndConsumeRecipeInputs(recipe, importInventory, this.getInputTank());
}

/**
* @param resultOverclock the overclock data to use. Format: {@code [EUt, duration]}.
* @return true if there is enough energy to continue recipe progress
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package gregtech.api.util;
package gregtech.api.creativetab;

import gregtech.api.util.GTLog;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
Expand All @@ -13,31 +15,32 @@ public class BaseCreativeTab extends CreativeTabs {
private final boolean hasSearchBar;
private final Supplier<ItemStack> iconSupplier;

public BaseCreativeTab(String TabName, Supplier<ItemStack> iconSupplier, boolean hasSearchBar) {
super(TabName);
public BaseCreativeTab(String tabName, Supplier<ItemStack> iconSupplier, boolean hasSearchBar) {
super(tabName);
this.iconSupplier = iconSupplier;
this.hasSearchBar = hasSearchBar;

if (hasSearchBar)
if (hasSearchBar) {
setBackgroundImageName("item_search.png");
}
}

@NotNull
@Override
public ItemStack createIcon() {
if (iconSupplier == null) {
GTLog.logger.error("Icon supplier was null for CreativeTab " + getTabLabel());
GTLog.logger.error("Icon supplier was null for CreativeTab {}", getTabLabel());
return new ItemStack(Blocks.STONE);
}

ItemStack stack = iconSupplier.get();
if (stack == null) {
GTLog.logger.error("Icon supplier return null for CreativeTab " + getTabLabel());
GTLog.logger.error("Icon supplier return null for CreativeTab {}", getTabLabel());
return new ItemStack(Blocks.STONE);
}

if (stack == ItemStack.EMPTY) {
GTLog.logger.error("Icon built from iconSupplied is EMPTY for CreativeTab " + getTabLabel());
if (stack.isEmpty()) {
GTLog.logger.error("Icon built from iconSupplied is EMPTY for CreativeTab {}", getTabLabel());
return new ItemStack(Blocks.STONE);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gregtech/api/items/armor/ArmorMetaItem.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package gregtech.api.items.armor;

import gregtech.api.GregTechAPI;
import gregtech.api.items.metaitem.MetaItem;
import gregtech.api.items.metaitem.stats.IEnchantabilityHelper;
import gregtech.api.items.metaitem.stats.IItemComponent;
import gregtech.common.creativetab.GTCreativeTabs;

import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.model.ModelBiped;
Expand Down Expand Up @@ -33,7 +33,7 @@ public class ArmorMetaItem<T extends ArmorMetaItem<?>.ArmorMetaValueItem> extend

public ArmorMetaItem() {
super((short) 0);
setCreativeTab(GregTechAPI.TAB_GREGTECH_TOOLS);
setCreativeTab(GTCreativeTabs.TAB_GREGTECH_TOOLS);
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gregtech.api.items.materialitem;

import gregtech.api.GTValues;
import gregtech.api.GregTechAPI;
import gregtech.api.damagesources.DamageSources;
import gregtech.api.items.armor.ArmorMetaItem;
import gregtech.api.items.metaitem.StandardMetaItem;
Expand All @@ -15,6 +14,7 @@
import gregtech.api.unification.material.registry.MaterialRegistry;
import gregtech.api.unification.ore.OrePrefix;
import gregtech.api.unification.stack.UnificationEntry;
import gregtech.common.creativetab.GTCreativeTabs;

import net.minecraft.block.BlockCauldron;
import net.minecraft.block.state.IBlockState;
Expand Down Expand Up @@ -58,7 +58,7 @@ public MetaPrefixItem(@NotNull MaterialRegistry registry, @NotNull OrePrefix ore
super();
this.registry = registry;
this.prefix = orePrefix;
this.setCreativeTab(GregTechAPI.TAB_GREGTECH_MATERIALS);
this.setCreativeTab(GTCreativeTabs.TAB_GREGTECH_MATERIALS);
}

@Override
Expand Down
Loading

0 comments on commit 5b91635

Please sign in to comment.