Skip to content

Commit

Permalink
Merge branch 'master' into zb-better-copying
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/gregtech/api/metatileentity/MetaTileEntity.java
#	src/main/java/gregtech/common/metatileentities/multi/multiblockpart/appeng/MetaTileEntityMEInputBus.java
#	src/main/java/gregtech/common/metatileentities/multi/multiblockpart/appeng/MetaTileEntityMEInputHatch.java
#	src/main/resources/assets/gregtech/lang/en_us.lang
#	src/main/resources/assets/gregtech/lang/ru_ru.lang
  • Loading branch information
Zorbatron committed Jan 22, 2025
2 parents c92a04a + 8fee80a commit a29e8cf
Show file tree
Hide file tree
Showing 576 changed files with 11,141 additions and 24,366 deletions.
4 changes: 2 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
dependencies {
// Published dependencies
api("codechicken:codechickenlib:3.2.3.358")
api("com.cleanroommc:modularui:2.5.0-rc1") { transitive = false }
api("com.cleanroommc:groovyscript:1.1.1") { transitive = false }
api("com.cleanroommc:modularui:2.5.0-rc2") { transitive = false }
api("com.cleanroommc:groovyscript:1.2.0-hotfix1") { transitive = false }
api("CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.700")
api("appeng:ae2-uel:v0.56.4") { transitive = false }
api rfg.deobf("curse.maven:ctm-267602:2915363") // CTM 1.0.2.31
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package meldexun.nothirium.api.renderer.chunk;

/**
* Adapted and minimized from <a
* href="https://github.com/Meldexun/Nothirium/blob/main/src/main/java/meldexun/nothirium/api/renderer/chunk/ChunkRenderPass.java">ChunkRenderPass.java</a>
*/
public enum ChunkRenderPass {
;

public static final ChunkRenderPass[] ALL = ChunkRenderPass.values();

}
2 changes: 1 addition & 1 deletion src/main/java/gregtech/GregTechMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
dependencies = "required:forge@[14.23.5.2847,);" + "required-after:codechickenlib@[3.2.3,);" +
"required-after:modularui@[2.3,);" + "required-after:mixinbooter@[8.0,);" + "after:appliedenergistics2;" +
"after:forestry;" + "after:extrabees;" + "after:extratrees;" + "after:genetics;" + "after:magicbees;" +
"after:jei@[4.15.0,);" + "after:crafttweaker@[4.1.20,);" + "after:groovyscript@[1.1.0,);" +
"after:jei@[4.15.0,);" + "after:crafttweaker@[4.1.20,);" + "after:groovyscript@[1.2.0,);" +
"after:theoneprobe;" + "after:hwyla;")
public class GregTechMod {

Expand Down
37 changes: 36 additions & 1 deletion src/main/java/gregtech/api/GTValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class GTValues {
* The Voltage Tiers. Use this Array instead of the old named Voltage Variables
*/
public static final long[] V = { 8, 32, 128, 512, 2048, 8192, 32768, 131072, 524288, 2097152, 8388608, 33554432,
134217728, 536870912, Integer.MAX_VALUE };
134217728, 536870912, 2147483648L };

/**
* The Voltage Tiers divided by 2.
Expand All @@ -74,6 +74,15 @@ public class GTValues {
public static final int[] VHA = { 7, 16, 60, 240, 960, 3840, 15360, 61440, 245760, 983040, 3932160, 15728640,
62914560, 251658240, 1006632960 };

/**
* The Voltage Tiers extended all the way to max Long value for overclocking
*/
public static final long[] VOC = { 8, 32, 128, 512, 2048, 8192, 32768, 131072, 524288, 2097152, 8388608, 33554432,
134217728, 536870912, 2147483648L, 8589934592L, 34359738368L, 137438953472L, 549755813888L,
2199023255552L, 8796093022208L, 35184372088832L, 140737488355328L, 562949953421312L, 2251799813685248L,
9007199254740992L, 36028797018963968L, 144115188075855872L, 576460752303423488L, 2305843009213693952L,
Long.MAX_VALUE };

public static final int ULV = 0;
public static final int LV = 1;
public static final int MV = 2;
Expand All @@ -90,13 +99,25 @@ public class GTValues {
public static final int UXV = 12;
public static final int OpV = 13;
public static final int MAX = 14;
public static final int MAX_TRUE = 30;

/**
* The short names for the voltages, used for registration primarily
*/
public static final String[] VN = new String[] { "ULV", "LV", "MV", "HV", "EV", "IV", "LuV", "ZPM", "UV", "UHV",
"UEV", "UIV", "UXV", "OpV", "MAX" };

/**
* The short names for the voltages, up to max Long, used for registration primarily
*/
public static final String[] VOCN = new String[] { "ULV", "LV", "MV", "HV", "EV", "IV", "LuV", "ZPM", "UV", "UHV",
"UEV", "UIV", "UXV", "OpV", "MAX", "MAX+1", "MAX+2", "MAX+3", "MAX+4", "MAX+5", "MAX+6", "MAX+7", "MAX+8",
"MAX+9", "MAX+10", "MAX+11", "MAX+12", "MAX+13", "MAX+14", "MAX+15", "MAX+16",
};

private static final String MAX_PLUS = RED.toString() + BOLD + "M" + YELLOW + BOLD + "A" + GREEN + BOLD + "X" +
AQUA + BOLD + "+" + LIGHT_PURPLE + BOLD;

/**
* The short names for the voltages, formatted for text
*/
Expand All @@ -107,6 +128,20 @@ public class GTValues {
DARK_RED + "UHV", GREEN + "UEV", DARK_GREEN + "UIV",
YELLOW + "UXV", BLUE + "OpV", RED.toString() + BOLD + "MAX" };

/**
* The short names for the voltages, up to max Long, formatted for text
*/
public static final String[] VOCNF = new String[] {
DARK_GRAY + "ULV", GRAY + "LV", AQUA + "MV",
GOLD + "HV", DARK_PURPLE + "EV", DARK_BLUE + "IV",
LIGHT_PURPLE + "LuV", RED + "ZPM", DARK_AQUA + "UV",
DARK_RED + "UHV", GREEN + "UEV", DARK_GREEN + "UIV",
YELLOW + "UXV", BLUE + "OpV", RED.toString() + BOLD + "MAX",
MAX_PLUS + "1", MAX_PLUS + "2", MAX_PLUS + "3", MAX_PLUS + "4",
MAX_PLUS + "5", MAX_PLUS + "6", MAX_PLUS + "7", MAX_PLUS + "8",
MAX_PLUS + "9", MAX_PLUS + "10", MAX_PLUS + "11", MAX_PLUS + "12",
MAX_PLUS + "13", MAX_PLUS + "14", MAX_PLUS + "15", MAX_PLUS + "16", };

/**
* Color values for the voltages
*/
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/gregtech/api/GregTechAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import gregtech.api.metatileentity.registry.MTEManager;
import gregtech.api.modules.IModuleManager;
import gregtech.api.network.INetworkHandler;
import gregtech.api.recipes.properties.RecipePropertyRegistry;
import gregtech.api.sound.ISoundManager;
import gregtech.api.unification.material.Material;
import gregtech.api.unification.material.registry.IMaterialRegistryManager;
Expand Down Expand Up @@ -56,6 +57,7 @@ public class GregTechAPI {
public static MTEManager mteManager;
/** GT's data migrations API */
public static final MigrationAPI MIGRATIONS = new MigrationAPI();
public static final RecipePropertyRegistry RECIPE_PROPERTIES = new RecipePropertyRegistry();

/** Will be available at the Pre-Initialization stage */
private static boolean highTier;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package gregtech.api.block;

import gregtech.api.recipes.recipeproperties.TemperatureProperty;
import gregtech.api.recipes.properties.impl.TemperatureProperty;
import gregtech.api.unification.material.Material;

import org.jetbrains.annotations.NotNull;
Expand Down
86 changes: 45 additions & 41 deletions src/main/java/gregtech/api/block/machines/BlockMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,34 +271,38 @@ public void onBlockPlacedBy(World worldIn, @NotNull BlockPos pos, @NotNull IBloc
Objects.requireNonNull(stack.getItem().getRegistryName()).getNamespace());

MetaTileEntity sampleMetaTileEntity = registry.getObjectById(stack.getItemDamage());
if (holder != null && sampleMetaTileEntity != null) {
// TODO Fix this
if (stack.hasDisplayName() && holder instanceof MetaTileEntityHolder) {
((MetaTileEntityHolder) holder).setCustomName(stack.getDisplayName());
}
MetaTileEntity metaTileEntity = holder.setMetaTileEntity(sampleMetaTileEntity);
var stackTag = stack.getTagCompound();
if (stackTag != null && !stackTag.isEmpty()) {
if (stackTag.hasKey(GregtechDataCodes.BLOCK_ENTITY_TAG)) {
var blockTag = stackTag.getCompoundTag(GregtechDataCodes.BLOCK_ENTITY_TAG);
String customName = blockTag.getString(GregtechDataCodes.CUSTOM_NAME);
if (!customName.isEmpty())
((MetaTileEntityHolder) holder).setCustomName(customName);

var mteTag = blockTag.getCompoundTag(GregtechDataCodes.TAG_KEY_MTE);
List<String> removed = new ArrayList<>();
for (var key : mteTag.getKeySet()) {
var trait = metaTileEntity.getMTETrait(key);
if (trait == null) continue;

removed.add(key);
}
removed.forEach(mteTag::removeTag);
metaTileEntity.readFromNBT(mteTag);
} else {
metaTileEntity.initFromItemStackData(stackTag);
if (holder == null || sampleMetaTileEntity == null)
return;

// TODO Fix this
if (stack.hasDisplayName() && holder instanceof MetaTileEntityHolder) {
((MetaTileEntityHolder) holder).setCustomName(stack.getDisplayName());
}
var stackTag = stack.getTagCompound();
NBTTagCompound mteTag = null;
if (stackTag != null && !stackTag.isEmpty()) {
if (stackTag.hasKey(GregtechDataCodes.BLOCK_ENTITY_TAG)) {
var blockTag = stackTag.getCompoundTag(GregtechDataCodes.BLOCK_ENTITY_TAG);
String customName = blockTag.getString(GregtechDataCodes.CUSTOM_NAME);
if (!customName.isEmpty())
((MetaTileEntityHolder) holder).setCustomName(customName);

mteTag = blockTag.getCompoundTag(GregtechDataCodes.TAG_KEY_MTE);
List<String> removed = new ArrayList<>();
for (var key : mteTag.getKeySet()) {
var trait = sampleMetaTileEntity.getMTETrait(key);
if (trait == null) continue;

removed.add(key);
}
removed.forEach(mteTag::removeTag);
}
}
MetaTileEntity metaTileEntity = holder.setMetaTileEntity(sampleMetaTileEntity, mteTag);
if (mteTag == null) {
if (stackTag != null && !stackTag.isEmpty())
metaTileEntity.initFromItemStackData(stackTag);

if (metaTileEntity.isValidFrontFacing(EnumFacing.UP)) {
metaTileEntity.setFrontFacing(EnumFacing.getDirectionFromEntityLiving(pos, placer));
} else {
Expand All @@ -314,26 +318,26 @@ public void onBlockPlacedBy(World worldIn, @NotNull BlockPos pos, @NotNull IBloc
}
}
}
if (Mods.AppliedEnergistics2.isModLoaded()) {
if (metaTileEntity.getProxy() != null) {
metaTileEntity.getProxy().setOwner((EntityPlayer) placer);
}
}
if (Mods.AppliedEnergistics2.isModLoaded()) {
if (metaTileEntity.getProxy() != null) {
metaTileEntity.getProxy().setOwner((EntityPlayer) placer);
}
}

// Color machines on place if holding spray can in off-hand
if (placer instanceof EntityPlayer) {
ItemStack offhand = placer.getHeldItemOffhand();
for (int i = 0; i < EnumDyeColor.values().length; i++) {
if (offhand.isItemEqual(MetaItems.SPRAY_CAN_DYES[i].getStackForm())) {
MetaItems.SPRAY_CAN_DYES[i].getBehaviours().get(0).onItemUse((EntityPlayer) placer, worldIn,
pos, EnumHand.OFF_HAND, EnumFacing.UP, 0, 0, 0);
break;
}
// Color machines on place if holding spray can in off-hand
if (placer instanceof EntityPlayer) {
ItemStack offhand = placer.getHeldItemOffhand();
for (int i = 0; i < EnumDyeColor.values().length; i++) {
if (offhand.isItemEqual(MetaItems.SPRAY_CAN_DYES[i].getStackForm())) {
MetaItems.SPRAY_CAN_DYES[i].getBehaviours().get(0).onItemUse((EntityPlayer) placer, worldIn,
pos, EnumHand.OFF_HAND, EnumFacing.UP, 0, 0, 0);
break;
}
}

metaTileEntity.onPlacement();
}

metaTileEntity.onPlacement(placer);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import gregtech.api.GTValues;
import gregtech.api.capability.impl.EUToFEProvider;
import gregtech.api.terminal.hardware.HardwareProvider;
import gregtech.api.util.GTUtility;
import gregtech.common.metatileentities.converter.ConverterTrait;

Expand All @@ -26,9 +25,6 @@ public class GregtechCapabilities {
@CapabilityInject(IMultiblockController.class)
public static Capability<IMultiblockController> CAPABILITY_MULTIBLOCK_CONTROLLER = null;

@CapabilityInject(HardwareProvider.class)
public static Capability<HardwareProvider> CAPABILITY_HARDWARE_PROVIDER = null;

@CapabilityInject(ConverterTrait.class)
public static Capability<ConverterTrait> CAPABILITY_CONVERTER = null;

Expand Down
46 changes: 46 additions & 0 deletions src/main/java/gregtech/api/capability/GregtechDataCodes.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
package gregtech.api.capability;

import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import org.apache.commons.lang3.ArrayUtils;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

public class GregtechDataCodes {

public static final int UPDATE_PRIVATE = assignId();
public static final int LOCK_FILL = assignId();
private static int nextId = 0;

public static int assignId() {
Expand Down Expand Up @@ -140,6 +149,11 @@ public static int assignId() {
public static final int UPDATE_ITEM_COUNT = assignId();
public static final int UPDATE_FLUID_AMOUNT = assignId();

// Quantum Storage Controller
public static final int UPDATE_CONTROLLER_POS = assignId();
public static final int REMOVE_CONTROLLER = assignId();
public static final int LOCATE_CONTROLLER = assignId();

// Detector Covers
public static final int UPDATE_INVERTED = assignId();

Expand Down Expand Up @@ -175,4 +189,36 @@ public static int assignId() {
// ME Parts
public static final int UPDATE_AUTO_PULL = assignId();
public static final int UPDATE_ONLINE_STATUS = assignId();

// Everything below MUST be last in the class!
public static final Int2ObjectMap<String> NAMES = new Int2ObjectArrayMap<>();

static {
registerFields(GregtechDataCodes.class);
}

public static String getNameFor(int id) {
return NAMES.getOrDefault(id, "Unknown_DataCode:" + id);
}

/**
* Registers all fields from the passed in class to the name registry.
* Optionally, you can pass in a list of valid ids to check against so that errant ids are not added
*
* @param clazz Class to iterate fields
* @param validIds optional array of valid ids to check against class fields
*/
public static void registerFields(Class<?> clazz, int... validIds) {
try {
for (Field field : clazz.getDeclaredFields()) {
if (field.getType() != Integer.TYPE) continue;
if (!Modifier.isStatic(field.getModifiers())) continue;
if (!Modifier.isFinal(field.getModifiers())) continue;
int id = field.getInt(null);
if (!ArrayUtils.isEmpty(validIds) && !ArrayUtils.contains(validIds, id))
continue;
NAMES.put(id, field.getName() + ":" + id);
}
} catch (IllegalAccessException ignored) {}
}
}
14 changes: 14 additions & 0 deletions src/main/java/gregtech/api/capability/IDualHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package gregtech.api.capability;

import net.minecraftforge.items.IItemHandler;

public interface IDualHandler {

boolean hasFluidTanks();

boolean hasItemHandlers();

IMultipleTankHandler getFluidTanks();

IItemHandler getItemHandlers();
}
34 changes: 34 additions & 0 deletions src/main/java/gregtech/api/capability/IQuantumController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package gregtech.api.capability;

import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.capabilities.ICapabilityProvider;

// ICapabilityProvider is needed because getCapability is called in the quantum proxy against this interface
public interface IQuantumController extends ICapabilityProvider {

/**
* Constructs the network upon placement and when storages are added/removed
* <br />
*/
void rebuildNetwork();

/**
* Return whether this storage block can connect. Can be used to implement a maximum distance from controller for
* example.
*/
boolean canConnect(IQuantumStorage<?> storage);

BlockPos getPos();

IDualHandler getHandler();

boolean isPowered();

long getEnergyUsage();

int getCount(IQuantumStorage.Type type);

long getTypeEnergy(IQuantumStorage<?> storage);

void updateHandler();
}
Loading

0 comments on commit a29e8cf

Please sign in to comment.