mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-21 12:32:29 +00:00
- Ported chest loot modification from ModTweaker
- Ported setLocalization from ModTweaker - Ported seed modification from ModTweaker - Fixed IClient setting - Added dev builds to the build script
This commit is contained in:
1 parent
2e34ac5c14
commit
aa2da58446
38 files changed
+2226
-50
No files matched your search
@@ -23,6 +23,7 @@ import minetweaker.api.recipes.IRecipeManager;
|
||||
import minetweaker.api.oredict.IOreDict;
|
||||
import minetweaker.api.recipes.IFurnaceManager;
|
||||
import minetweaker.api.server.IServer;
|
||||
import minetweaker.api.vanilla.IVanilla;
|
||||
import minetweaker.runtime.GlobalRegistry;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenExpansion;
|
||||
@@ -90,6 +91,7 @@ public class MineTweakerAPI {
|
||||
registerGlobalSymbol("game", getJavaStaticFieldSymbol(MineTweakerAPI.class, "game"));
|
||||
registerGlobalSymbol("loadedMods", getJavaStaticFieldSymbol(MineTweakerAPI.class, "loadedMods"));
|
||||
registerGlobalSymbol("format", getJavaStaticFieldSymbol(MineTweakerAPI.class, "format"));
|
||||
registerGlobalSymbol("vanilla", getJavaStaticFieldSymbol(MineTweakerAPI.class, "vanilla"));
|
||||
}
|
||||
|
||||
private MineTweakerAPI() {}
|
||||
@@ -156,6 +158,11 @@ public class MineTweakerAPI {
|
||||
*/
|
||||
public static IFormatter format = null;
|
||||
|
||||
/**
|
||||
* Access point to the vanilla functions and data.
|
||||
*/
|
||||
public static IVanilla vanilla = null;
|
||||
|
||||
/**
|
||||
* Applies this given action.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package minetweaker;
|
||||
|
||||
import minetweaker.api.logger.MTLogger;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@@ -23,7 +22,9 @@ import minetweaker.api.formatting.IFormatter;
|
||||
import minetweaker.api.game.IGame;
|
||||
import minetweaker.api.item.IItemDefinition;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.item.WeightedItemStack;
|
||||
import minetweaker.api.liquid.ILiquidDefinition;
|
||||
import minetweaker.api.logger.MTLogger;
|
||||
import minetweaker.api.mods.ILoadedMods;
|
||||
import minetweaker.api.mods.IMod;
|
||||
import minetweaker.api.oredict.IOreDict;
|
||||
@@ -34,6 +35,8 @@ import minetweaker.api.recipes.IRecipeManager;
|
||||
import minetweaker.api.server.ICommandFunction;
|
||||
import minetweaker.api.server.ICommandValidator;
|
||||
import minetweaker.api.server.IServer;
|
||||
import minetweaker.api.vanilla.IVanilla;
|
||||
import minetweaker.api.vanilla.LootEntry;
|
||||
import minetweaker.api.world.IBiome;
|
||||
import minetweaker.runtime.IScriptProvider;
|
||||
import minetweaker.util.EventList;
|
||||
@@ -290,6 +293,60 @@ public class MineTweakerImplementationAPI {
|
||||
}
|
||||
}));
|
||||
|
||||
minetweakerCommands.put("seeds", new MineTweakerCommand(
|
||||
"seeds",
|
||||
new String[] {
|
||||
"/minetweaker seeds",
|
||||
" Prints all seeds registered",
|
||||
" for tall grass"
|
||||
}, new ICommandFunction() {
|
||||
@Override
|
||||
public void execute(String[] arguments, IPlayer player) {
|
||||
MineTweakerAPI.logCommand("Seeds:");
|
||||
for (WeightedItemStack seed : MineTweakerAPI.vanilla.getSeeds().getSeeds()) {
|
||||
String message = seed.getStack() + " - " + (int) seed.getChance();
|
||||
player.sendChat(message);
|
||||
MineTweakerAPI.logCommand("Seed: " + message);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
minetweakerCommands.put("loot", new MineTweakerCommand(
|
||||
"seeds",
|
||||
new String[] {
|
||||
"/minetweaker seeds",
|
||||
" Prints all seeds registered",
|
||||
" for tall grass"
|
||||
}, new ICommandFunction() {
|
||||
@Override
|
||||
public void execute(String[] arguments, IPlayer player) {
|
||||
if (arguments.length == 0) {
|
||||
MineTweakerAPI.logCommand("Loot chest contents:");
|
||||
List<String> types = MineTweakerAPI.vanilla.getLoot().getLootTypes();
|
||||
Collections.sort(types);
|
||||
for (String lootType : types) {
|
||||
MineTweakerAPI.logCommand("Loot type: " + lootType);
|
||||
|
||||
List<LootEntry> entries = MineTweakerAPI.vanilla.getLoot().getLoot(lootType);
|
||||
for (LootEntry entry : entries) {
|
||||
MineTweakerAPI.logCommand(" " + entry.toString());
|
||||
}
|
||||
}
|
||||
|
||||
player.sendChat("List generated; see minetweaker.log in your minecraft dir");
|
||||
} else {
|
||||
MineTweakerAPI.logCommand("Loot for type: " + arguments[0]);
|
||||
|
||||
List<LootEntry> entries = MineTweakerAPI.vanilla.getLoot().getLoot(arguments[0]);
|
||||
for (LootEntry entry : entries) {
|
||||
MineTweakerAPI.logCommand(" " + entry.toString());
|
||||
}
|
||||
|
||||
player.sendChat("List generated; see minetweaker.log in your minecraft dir");
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
minetweakerCommands.put("wiki", new MineTweakerCommand(
|
||||
"wiki",
|
||||
new String[] {
|
||||
@@ -396,6 +453,7 @@ public class MineTweakerImplementationAPI {
|
||||
* @param game game interface
|
||||
* @param mods mods interface
|
||||
* @param formatter formatter interface
|
||||
* @param vanilla vanilla interface
|
||||
*/
|
||||
public static void init(
|
||||
IOreDict oreDict,
|
||||
@@ -403,13 +461,15 @@ public class MineTweakerImplementationAPI {
|
||||
IFurnaceManager furnace,
|
||||
IGame game,
|
||||
ILoadedMods mods,
|
||||
IFormatter formatter) {
|
||||
IFormatter formatter,
|
||||
IVanilla vanilla) {
|
||||
MineTweakerAPI.oreDict = oreDict;
|
||||
MineTweakerAPI.recipes = recipes;
|
||||
MineTweakerAPI.furnace = furnace;
|
||||
MineTweakerAPI.game = game;
|
||||
MineTweakerAPI.loadedMods = mods;
|
||||
MineTweakerAPI.format = formatter;
|
||||
MineTweakerAPI.vanilla = vanilla;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -530,6 +590,7 @@ public class MineTweakerImplementationAPI {
|
||||
|
||||
private static class AddMineTweakerCommandAction implements IUndoableAction {
|
||||
private final MineTweakerCommand command;
|
||||
private boolean added;
|
||||
|
||||
public AddMineTweakerCommandAction(MineTweakerCommand command) {
|
||||
this.command = command;
|
||||
@@ -537,7 +598,12 @@ public class MineTweakerImplementationAPI {
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
minetweakerCommands.put(command.name, command);
|
||||
if (!minetweakerCommands.containsKey(command.name)) {
|
||||
minetweakerCommands.put(command.name, command);
|
||||
added = true;
|
||||
} else {
|
||||
added = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -547,7 +613,9 @@ public class MineTweakerImplementationAPI {
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
minetweakerCommands.remove(command.name);
|
||||
if (added) {
|
||||
minetweakerCommands.remove(command.name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,4 +18,7 @@ public interface IClient {
|
||||
*/
|
||||
@ZenGetter("player")
|
||||
public IPlayer getPlayer();
|
||||
|
||||
@ZenGetter("language")
|
||||
public String getLanguage();
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import minetweaker.api.liquid.ILiquidDefinition;
|
||||
import minetweaker.api.world.IBiome;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
* Game interface. Used to obtain general game information.
|
||||
@@ -55,4 +56,42 @@ public interface IGame {
|
||||
*/
|
||||
@ZenGetter("entities")
|
||||
public List<IEntityDefinition> getEntities();
|
||||
|
||||
/**
|
||||
* Sets a localization value.
|
||||
*
|
||||
* @param key localization key
|
||||
* @param value localization value
|
||||
*/
|
||||
@ZenMethod
|
||||
public void setLocalization(String key, String value);
|
||||
|
||||
/**
|
||||
* Sets a localization value.
|
||||
*
|
||||
* @param lang language
|
||||
* @param key localization key
|
||||
* @param value localization value
|
||||
*/
|
||||
@ZenMethod
|
||||
public void setLocalization(String lang, String key, String value);
|
||||
|
||||
/**
|
||||
* Gets a localized string.
|
||||
*
|
||||
* @param key localization key
|
||||
* @return localized value
|
||||
*/
|
||||
@ZenMethod
|
||||
public String localize(String key);
|
||||
|
||||
/**
|
||||
* Gets a localized string.
|
||||
*
|
||||
* @param key localization key
|
||||
* @param lang language
|
||||
* @return localized value
|
||||
*/
|
||||
@ZenMethod
|
||||
public String localize(String key, String lang);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.vanilla;
|
||||
|
||||
import java.util.List;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.WeightedItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("vanilla.ILootRegistry")
|
||||
public interface ILootRegistry {
|
||||
@ZenMethod
|
||||
public void addChestLoot(String name, WeightedItemStack item);
|
||||
|
||||
@ZenMethod
|
||||
public void addChestLoot(String name, WeightedItemStack item, int min, int max);
|
||||
|
||||
@ZenMethod
|
||||
public void removeChestLoot(String name, IIngredient ingredient);
|
||||
|
||||
@ZenMethod
|
||||
public List<LootEntry> getLoot(String name);
|
||||
|
||||
@ZenGetter("lootTypes")
|
||||
public List<String> getLootTypes();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.vanilla;
|
||||
|
||||
import java.util.List;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.WeightedItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("vanilla.ISeedRegistry")
|
||||
public interface ISeedRegistry {
|
||||
@ZenMethod
|
||||
public void addSeed(WeightedItemStack item);
|
||||
|
||||
@ZenMethod
|
||||
public void removeSeed(IIngredient item);
|
||||
|
||||
@ZenGetter("seeds")
|
||||
public List<WeightedItemStack> getSeeds();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.vanilla;
|
||||
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("vanilla.IVanilla")
|
||||
public interface IVanilla {
|
||||
@ZenGetter("loot")
|
||||
public ILootRegistry getLoot();
|
||||
|
||||
@ZenGetter("seeds")
|
||||
public ISeedRegistry getSeeds();
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.vanilla;
|
||||
|
||||
import minetweaker.api.item.WeightedItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenGetter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenClass("vanilla.LootEntry")
|
||||
public class LootEntry {
|
||||
private final WeightedItemStack item;
|
||||
private final int minAmount;
|
||||
private final int maxAmount;
|
||||
|
||||
public LootEntry(WeightedItemStack item, int minAmount, int maxAmount) {
|
||||
this.item = item;
|
||||
this.minAmount = minAmount;
|
||||
this.maxAmount = maxAmount;
|
||||
}
|
||||
|
||||
@ZenGetter("item")
|
||||
public WeightedItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
@ZenGetter("minAmount")
|
||||
public int getMinAmount() {
|
||||
return minAmount;
|
||||
}
|
||||
|
||||
@ZenGetter("maxAmount")
|
||||
public int getMaxAmount() {
|
||||
return maxAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder message = new StringBuilder();
|
||||
message.append(getItem().getStack());
|
||||
message.append(" (weight ");
|
||||
message.append((int) getItem().getChance());
|
||||
if (getMinAmount() != 0 || getMaxAmount() != 1) {
|
||||
message.append(", ");
|
||||
message.append(getMinAmount());
|
||||
message.append("-");
|
||||
message.append(getMaxAmount());
|
||||
}
|
||||
message.append(")");
|
||||
|
||||
return message.toString();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user