Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 42 additions & 16 deletions src/main/java/com/newmaa/othtech/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,55 @@ public class Config {
public static void synchronizeConfiguration(File configFile) {

Configuration configuration = new Configuration(configFile);
// TODO NEED ENGLISH TRANSLATION O.O

// greeting = configuration.getString("greeting", Configuration.CATEGORY_GENERAL, greeting, "How shall I
// greet?");
is_TT_Boom = configuration.getBoolean("OTHTechnology : 控制TT模版机器爆炸", "憋憋", is_TT_Boom, "憋憋");
NEIFrontend = configuration
.getBoolean("OTHTechnology : 123机器配方池界面使用铱锇钐合金粉替换GT齿轮, true为是, false为替换成憋憋", "A", NEIFrontend, "A");
is_TT_Boom = configuration.getBoolean(
"OTHTechnology : Control TT Machine Explosion | 控制TT模版机器爆炸",
"Machine Settings",
is_TT_Boom,
"Enable/disable TT template machine explosions | 憋憋");
NEIFrontend = configuration.getBoolean(
"OTHTechnology : Use Iridium-Osmium-Samarium Powder in Recipe GUI | 123机器配方池界面使用铱锇钐合金粉替换GT齿轮, true为是, false为替换成憋憋",
"UI Settings",
NEIFrontend,
"true: use Ir-Os-Sm powder instead of GT gears, false: use alternative | true为是, false为替换成憋憋");
is_MISA_IMBA_Recipes_Enabled = configuration.getBoolean(
"OTHTechnology : 艾萨集成工厂超模配方是否开启(e.g. 无尽催化剂矿出无尽粉 黑钚矿出黑中子粉), true为是, false为否",
"A",
"OTHTechnology : Enable MISA Overpowered Recipes | 艾萨集成工厂超模配方是否开启(e.g. 无尽催化剂矿出无尽粉 黑钚矿出黑中子粉), true为是, false为否",
"Recipe Settings",
is_MISA_IMBA_Recipes_Enabled,
"A");
"Enable overpowered recipes in MISA Integrated Factory (e.g. infinite catalyst ore -> infinite dust) | true为是, false为否");
is_EggMachine_Recipes_For_NHU = configuration.getBoolean(
"OTHTechnology : 丰矿的NHU配方兼容从123大龙研机(e.g. 一步到位顶级蛋机 龙蛋馄饨龙蛋远古龙蛋配方), true为是, false为否",
"A",
"OTHTechnology : Enable NHU Recipes for Egg Machine | 丰矿的NHU配方兼容从123大龙研机(e.g. 一步到位顶级蛋机 龙蛋馄饨龙蛋远古龙蛋配方), true为是, false为否",
"Recipe Settings",
is_EggMachine_Recipes_For_NHU,
"A");
ENQING_MULTI = configuration
.getFloat("OTHTechnology : 恩情工厂配方产物倍率(float) , 倍率四舍五入", "不憋憋", 1.5f, 1.0f, 114514f, "不憋憋");
tier_Antimonia = configuration.getInt("OTHTechnology : 锑星登陆需求等级(Tier)", "不憋憋", 4, 1, 10, "笑笑");
tier_Ross123b = configuration.getInt("OTHTechnology : 锑罗斯登陆需求等级(Tier)", "不憋憋", 1, 1, 10, "笑笑");
is_Enqing_Song_Play = configuration
.getBoolean("OTHTechnology : 开启将军工厂的开机音效, true为是, false为否", "A", is_Enqing_Song_Play, "A");
"Enable NHU recipes compatibility (e.g. one-step dragon egg recipes) | true为是, false为否");
ENQING_MULTI = configuration.getFloat(
"OTHTechnology : Enqing Factory Output Multiplier (float, rounded) | 恩情工厂配方产物倍率(float) , 倍率四舍五入",
"Multipliers",
1.5f,
1.0f,
114514f,
"Output multiplier for Enqing Factory recipes (rounded to nearest integer) | 倍率四舍五入");
tier_Antimonia = configuration.getInt(
"OTHTechnology : Antimonia Planet Landing Tier Requirement | 锑星登陆需求等级(Tier)",
"Dimension Settings",
4,
1,
10,
"Required tier to land on Antimonia planet | 笑笑");
tier_Ross123b = configuration.getInt(
"OTHTechnology : Ross123b Planet Landing Tier Requirement | 锑罗斯登陆需求等级(Tier)",
"Dimension Settings",
1,
1,
10,
"Required tier to land on Ross123b planet | 笑笑");
is_Enqing_Song_Play = configuration.getBoolean(
"OTHTechnology : Enable General Factory Startup Sound | 开启将军工厂的开机音效, true为是, false为否",
"Audio Settings",
is_Enqing_Song_Play,
"Enable/disable General Factory startup sound effect | true为是, false为否");
if (configuration.hasChanged()) {
configuration.save();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ public EntityFakePlayer(World world) {

@Override
protected void dropFewItems(boolean wasRecentlyHit, int lootingModifier) {
{
this.dropItem(ItemLoader.itemBrain, 1);
}
this.dropItem(ItemLoader.itemBrain, 1);
int extraDrops = this.rand.nextInt(8 + lootingModifier);
for (int i = 0; i < extraDrops; ++i) {
this.dropItem(ModItems.itemMetaFood, 36);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.newmaa.othtech.common.item.itemsHelper;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
Expand All @@ -26,16 +28,12 @@
*/
public class ItemAdder extends ItemAdder_Basic {

/**
* An Item Map for managing basic items
*/
// public static Map<String, ItemAdder> Item01Map = new HashMap<>();

/**
* A Set contains the meta value that has been used.
* Thread-safe to prevent race conditions during concurrent access.
*/
public static final Set<Integer> MetaSet = new HashSet<>();
public static final Map<Integer, String[]> MetaItemTooltipsMap = new HashMap<>();
public static final Set<Integer> MetaSet = Collections.synchronizedSet(new HashSet<>());
public static final Map<Integer, String[]> MetaItemTooltipsMap = new ConcurrentHashMap<>();

public final String unlocalizedName;

Expand Down Expand Up @@ -71,15 +69,6 @@ public static ItemStack initItem(String aName, int aMeta, String[] tooltips) {

}

/**
* Init the basic items at the game pre init.
*/
// public static void init() {
// for (String MetaName : Item01Map.keySet()) {
// GameRegistry.registerItem(Item01Map.get(MetaName), MetaName);
// }
// }

// region Overrides

@Override
Expand Down
96 changes: 59 additions & 37 deletions src/main/java/com/newmaa/othtech/machine/OTELargeBin.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,19 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a
if (Tier >= 5) {
Tier = 0;
}
return Tier == 1 ? checkPiece(Tier1, 2, 3, 1)
: Tier == 2 ? checkPiece(Tier2, 4, 9, 2)
: Tier == 3 ? checkPiece(Tier3, 7, 18, 3)
: Tier == 4 ? checkPiece(Tier4, 9, 27, 1) : checkPiece(Tier1, 2, 3, 1);


switch (Tier) {
case 1:
return checkPiece(Tier1, 2, 3, 1);
case 2:
return checkPiece(Tier2, 4, 9, 2);
case 3:
return checkPiece(Tier3, 7, 18, 3);
case 4:
return checkPiece(Tier4, 9, 27, 1);
default:
return checkPiece(Tier1, 2, 3, 1);
}
}

@Override
Expand All @@ -116,12 +124,19 @@ public void construct(ItemStack stackSize, boolean hintsOnly) {
public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) {
if (mMachine) return -1;
Tier = stackSize.stackSize;
return Tier == 1 ? survivalBuildPiece(Tier1, stackSize, 2, 3, 1, elementBudget, source, actor, false, true)
: Tier == 2 ? survivalBuildPiece(Tier2, stackSize, 4, 9, 2, elementBudget, source, actor, false, true)
: Tier == 3 ? survivalBuildPiece(Tier3, stackSize, 7, 18, 3, elementBudget, source, actor, false, true)
: Tier == 4
? survivalBuildPiece(Tier4, stackSize, 9, 27, 1, elementBudget, source, actor, false, true)
: survivalBuildPiece(Tier1, stackSize, 2, 3, 1, elementBudget, source, actor, false, true);

switch (Tier) {
case 1:
return survivalBuildPiece(Tier1, stackSize, 2, 3, 1, elementBudget, source, actor, false, true);
case 2:
return survivalBuildPiece(Tier2, stackSize, 4, 9, 2, elementBudget, source, actor, false, true);
case 3:
return survivalBuildPiece(Tier3, stackSize, 7, 18, 3, elementBudget, source, actor, false, true);
case 4:
return survivalBuildPiece(Tier4, stackSize, 9, 27, 1, elementBudget, source, actor, false, true);
default:
return survivalBuildPiece(Tier1, stackSize, 2, 3, 1, elementBudget, source, actor, false, true);
}
}

@Override
Expand Down Expand Up @@ -566,14 +581,16 @@ public CheckRecipeResult checkProcessing() {
if (mode == 0) {
mEUt = 0;
mMaxProgresstime = getBaseProgressingTick();
ItemStack[] itemStack = getStoredInputsNoSeparation().toArray(new ItemStack[0]);
FluidStack[] fluidStack = getStoredFluids().toArray(new FluidStack[0]);
if (getStoredInputsNoSeparation() != null) {
Collection<ItemStack> storedInputs = getStoredInputsNoSeparation();
if (storedInputs != null) {
ItemStack[] itemStack = storedInputs.toArray(new ItemStack[0]);
for (ItemStack item : itemStack) {
item.stackSize -= item.stackSize;
}
}
if (getStoredFluids() != null) {
Collection<FluidStack> storedFluids = getStoredFluids();
if (storedFluids != null) {
FluidStack[] fluidStack = storedFluids.toArray(new FluidStack[0]);
for (FluidStack fluid : fluidStack) {
fluid.amount -= fluid.amount;
}
Expand All @@ -582,32 +599,37 @@ public CheckRecipeResult checkProcessing() {
} else if (mode == 1) {
mMaxProgresstime = getBaseProgressingTick();
int a;
ItemStack[] itemStack = getStoredInputsNoSeparation().toArray(new ItemStack[0]);
for (ItemStack item : itemStack) {
if (item.stackSize <= getMaxParallelRecipes()) {
a = item.stackSize;
mEUt = (30 * a);
item.stackSize -= item.stackSize;
mOutputItems = new ItemStack[] {
setStackSize(ItemList.IC2_Scrap.get(1), (int) Math.floor(a * 0.5)) };
} else {
a = getMaxParallelRecipes();
mEUt = (30 * a);
item.stackSize -= getMaxParallelRecipes();
mOutputItems = new ItemStack[] {
setStackSize(ItemList.IC2_Scrap.get(1), (int) Math.floor(a * 0.5)) };
Collection<ItemStack> storedInputs = getStoredInputsNoSeparation();
if (storedInputs != null) {
ItemStack[] itemStack = storedInputs.toArray(new ItemStack[0]);
for (ItemStack item : itemStack) {
if (item.stackSize <= getMaxParallelRecipes()) {
a = item.stackSize;
mEUt = (30 * a);
item.stackSize -= item.stackSize;
mOutputItems = new ItemStack[] {
setStackSize(ItemList.IC2_Scrap.get(1), (int) Math.floor(a * 0.5)) };
} else {
a = getMaxParallelRecipes();
mEUt = (30 * a);
item.stackSize -= getMaxParallelRecipes();
mOutputItems = new ItemStack[] {
setStackSize(ItemList.IC2_Scrap.get(1), (int) Math.floor(a * 0.5)) };
}
}
}
} else if (mode == 2) {
mMaxProgresstime = getBaseProgressingTick();
ItemStack[] itemStack = getStoredInputsNoSeparation().toArray(new ItemStack[0]);
for (ItemStack item : itemStack) {
if (item.stackSize >= 256000) {
mSA += 256000;
item.stackSize -= 256000;
if (mSA >= 256000) {
mOutputItems = new ItemStack[] {
GTModHandler.getModItem(AppliedEnergistics2.ID, "item.ItemMultiMaterial", 1, 47) };
Collection<ItemStack> storedInputs = getStoredInputsNoSeparation();
if (storedInputs != null) {
ItemStack[] itemStack = storedInputs.toArray(new ItemStack[0]);
for (ItemStack item : itemStack) {
if (item.stackSize >= 256000) {
mSA += 256000;
item.stackSize -= 256000;
if (mSA >= 256000) {
mOutputItems = new ItemStack[] {
GTModHandler.getModItem(AppliedEnergistics2.ID, "item.ItemMultiMaterial", 1, 47) };
mSA -= 256000;
}
} else {
Expand Down
21 changes: 17 additions & 4 deletions src/main/java/com/newmaa/othtech/machine/OTEMegaQFT.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,18 @@ public OTEMegaQFT(String aName) {
private byte mode = 0;
private int multiplier = 1;
private String plier = "0";

// NBT version for backward compatibility
private static final int NBT_VERSION = 1;
// Maximum time acceleration level (10 = 100% speedup, based on getSpeedBonus formula)
private static final int MAX_TIME_ACCELERATION = 10;


@Override
public void saveNBTData(NBTTagCompound aNBT) {
super.saveNBTData(aNBT);

aNBT.setInteger("nbtVersion", NBT_VERSION);
aNBT.setInteger("stabilisationFieldMetadata", stabilisationFieldMetadata);
aNBT.setInteger("spacetimeCompressionFieldMetadata", spacetimeCompressionFieldMetadata);
aNBT.setInteger("timeAccelerationFieldMetadata", timeAccelerationFieldMetadata);
Expand All @@ -86,11 +92,18 @@ public void saveNBTData(NBTTagCompound aNBT) {
public void loadNBTData(final NBTTagCompound aNBT) {
super.loadNBTData(aNBT);

stabilisationFieldMetadata = aNBT.getInteger("stabilisationFieldMetadata");
spacetimeCompressionFieldMetadata = aNBT.getInteger("spacetimeCompressionFieldMetadata");
timeAccelerationFieldMetadata = aNBT.getInteger("timeAccelerationFieldMetadata");
// Check NBT version for compatibility - future versions can add migration logic here
int nbtVersion = aNBT.hasKey("nbtVersion") ? aNBT.getInteger("nbtVersion") : 0;

// Version 0 (legacy): Load without validation
// Version 1: Load with bounds checking and sanitization

// Sanitize and validate input values with bounds checking
stabilisationFieldMetadata = Math.max(0, aNBT.getInteger("stabilisationFieldMetadata"));
spacetimeCompressionFieldMetadata = Math.max(0, aNBT.getInteger("spacetimeCompressionFieldMetadata"));
timeAccelerationFieldMetadata = Math.max(0, Math.min(MAX_TIME_ACCELERATION, aNBT.getInteger("timeAccelerationFieldMetadata")));
mode = aNBT.getByte("mode");
multiplier = aNBT.getInteger("multiplier");
multiplier = Math.max(1, aNBT.getInteger("multiplier"));

}

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

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
Expand Down Expand Up @@ -56,7 +57,8 @@ public class OTEHatchRack extends MTEHatch implements IAddGregtechLogo, IAddUIWi
private static Textures.BlockIcons.CustomIcon EM_R;
private static Textures.BlockIcons.CustomIcon EM_R_ACTIVE;
private float overClock = 1, overVolt = 1;
private static final Map<String, RackComponent> componentBinds = new HashMap<>();
// Thread-safe map to prevent race conditions during concurrent access
private static final Map<String, RackComponent> componentBinds = new ConcurrentHashMap<>();

private String clientLocale = "en_US";

Expand Down
Loading
Loading