mirror of
https://github.com/GTNewHorizons/IguanaTweaksTConstruct.git
synced 2026-11-26 06:43:05 +00:00
Correctly apply the new Random Modifiers!
This commit is contained in:
1 parent
b12315cc5a
commit
32b09565a4
3 files changed
+29
-25
No files matched your search
@@ -28,8 +28,6 @@ import java.util.List;
|
||||
|
||||
// inofficial todo list:
|
||||
// todo: find a solution to stone-head-tools not having xp even when head is replaced (maybe like old iguana, disallow stone tools?)
|
||||
// todo: PR a ToolModifyEvent in ModifyBuilder to Tinkers to update XP when a modifier that modifies XP needed is applied.
|
||||
// todo: refactor adding modifiers on levelup from that long chaotic function + normal modifiers ;o
|
||||
|
||||
@Mod(modid= Reference.MOD_ID, name= Reference.MOD_NAME, version="1.7.X-1p",
|
||||
dependencies = "required-after:" + Reference.TCON_MOD_ID + ";after:*")
|
||||
|
||||
@@ -299,9 +299,7 @@ public abstract class LevelingLogic {
|
||||
// Add random bonuses on leveling up?
|
||||
if (Config.toolLevelingRandomBonuses)
|
||||
{
|
||||
tags.setInteger("Modifiers", currentModifiers + 1);
|
||||
for (int i = 1; i <= 10; ++i) if (tryModify(player, stack, world.rand.nextInt(10), isTool)) break;
|
||||
tags.setInteger("Modifiers", currentModifiers);
|
||||
RandomBonusses.tryModifying(player, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,6 +330,7 @@ public abstract class LevelingLogic {
|
||||
tags.setInteger("HarvestLevel", tags.getInteger("HarvestLevel") + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
private static boolean tryModify(EntityPlayer player, ItemStack stack, int rnd, boolean isTool)
|
||||
{
|
||||
ItemModifier mod = null;
|
||||
@@ -421,4 +420,5 @@ public abstract class LevelingLogic {
|
||||
mod.modify(nullItemStack, stack);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.crafting.ModifyBuilder;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
import tconstruct.modifiers.tools.ModRedstone;
|
||||
@@ -19,31 +20,36 @@ import java.util.Set;
|
||||
public class RandomBonusses {
|
||||
private static Map<String, ItemModifier> modCache = new HashMap<String, ItemModifier>();
|
||||
|
||||
public static void tryModifying(EntityPlayer player, ItemStack tool, int i, boolean isTool)
|
||||
public static void tryModifying(EntityPlayer player, ItemStack tool)
|
||||
{
|
||||
boolean modified = true;
|
||||
boolean modified = false;
|
||||
// add a modifier for it
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
tags.setInteger("Modifiers", tags.getInteger("Modifiers")+1);
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
tags.setInteger("Modifiers", modifiers+1);
|
||||
|
||||
if(i-- == 0) addRedstoneModifier(player, tool);
|
||||
if(i-- == 0) addLapisModifier(player, tool);
|
||||
//if(i-- == 0) addAutoSmeltModifier(player, tool);
|
||||
//if(i-- == 0) addSilktouchModifier(player, tool);
|
||||
//if(i-- == 0) addDiamondModifier(player, tool);
|
||||
//if(i-- == 0) addEmeraldModifier(player, tool);
|
||||
if(i-- == 0) addRepairModifier(player, tool);
|
||||
if(i-- == 0) addAttackModifier(player, tool);
|
||||
if(i-- == 0) addBlazeModifier(player, tool);
|
||||
if(i-- == 0) addSmiteModifier(player, tool);
|
||||
if(i-- == 0) addAntiSpiderModifier(player, tool);
|
||||
if(i-- == 0) addBeheadingModifier(player, tool);
|
||||
if(i-- == 0) addLifeStealModifier(player, tool);
|
||||
if(i-- == 0) addKnockbackModifier(player, tool);
|
||||
// we can do this without getting an infinite loop, because redstone, lapis,... can be applied infinitely often
|
||||
while(!modified) {
|
||||
int i = TConstruct.random.nextInt(14);
|
||||
Log.info("Trying modifier # " + i);
|
||||
if (i-- == 0) modified = addRedstoneModifier(player, tool); //0
|
||||
if (i-- == 0) modified = addLapisModifier(player, tool); //1
|
||||
if (i-- == 0) modified = addAutoSmeltModifier(player, tool); //2
|
||||
if (i-- == 0) modified = addSilktouchModifier(player, tool); //3
|
||||
if (i-- == 0) modified = addDiamondModifier(player, tool); //4
|
||||
if (i-- == 0) modified = addEmeraldModifier(player, tool); //5
|
||||
if (i-- == 0) modified = addRepairModifier(player, tool); //6
|
||||
if (i-- == 0) modified = addAttackModifier(player, tool); //7
|
||||
if (i-- == 0) modified = addBlazeModifier(player, tool); //8
|
||||
if (i-- == 0) modified = addSmiteModifier(player, tool); //9
|
||||
if (i-- == 0) modified = addAntiSpiderModifier(player, tool);//10
|
||||
if (i-- == 0) modified = addBeheadingModifier(player, tool); //11
|
||||
if (i-- == 0) modified = addLifeStealModifier(player, tool); //12
|
||||
if (i-- == 0) modified = addKnockbackModifier(player, tool); //13
|
||||
}
|
||||
|
||||
// no modifier applicable? remove the added modifier again
|
||||
if(!modified)
|
||||
tags.setInteger("Modifiers", tags.getInteger("Modifiers")-1);
|
||||
// restore modifiers
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user