mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-23 21:39:40 +00:00
- Fixed right-clicking mid-air crashing the client
- Fixed bracket handlers not working - Improved implementation of rebuilding internal item registry at server start
This commit is contained in:
1 parent
ad7b02c1ed
commit
3e33904edd
6 files changed
+31
-12
No files matched your search
@@ -155,9 +155,8 @@ public class MineTweakerMod {
|
||||
public void onServerAboutToStart(FMLServerAboutToStartEvent ev) {
|
||||
// starts before loading worlds
|
||||
// perfect place to start MineTweaker!
|
||||
for (String itemName : (Set<String>) Item.itemRegistry.getKeys()) {
|
||||
ItemBracketHandler.itemNames.put(itemName.replace(" ", ""), (Item) Item.itemRegistry.getObject(itemName));
|
||||
}
|
||||
ItemBracketHandler.rebuildItemRegistry();
|
||||
|
||||
if (MineTweakerPlatformUtils.isClient()) {
|
||||
MineTweakerAPI.client = new MCClient();
|
||||
}
|
||||
|
||||
+11
-1
@@ -36,8 +36,18 @@ import stanhebben.zenscript.util.ZenPosition;
|
||||
*/
|
||||
@BracketHandler(priority = 100)
|
||||
public class ItemBracketHandler implements IBracketHandler {
|
||||
public static final Map<String, Item> itemNames = new HashMap<String, Item>();
|
||||
private static final Map<String, Item> itemNames = new HashMap<String, Item>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void rebuildItemRegistry()
|
||||
{
|
||||
itemNames.clear();
|
||||
|
||||
for (String itemName : (Set<String>) Item.itemRegistry.getKeys()) {
|
||||
itemNames.put(itemName.replace(" ", ""), (Item) Item.itemRegistry.getObject(itemName));
|
||||
}
|
||||
}
|
||||
|
||||
public static IItemStack getItem(String name, int meta) {
|
||||
// Item item = (Item) Item.itemRegistry.getObject(name);
|
||||
Item item = itemNames.get(name);
|
||||
|
||||
@@ -39,6 +39,14 @@ dependencies {
|
||||
compile project(':MineTweaker3-API')
|
||||
}
|
||||
|
||||
task makeRegistry(type: RegisterZenClassesTask) {
|
||||
inputDir = file('build/classes/main')
|
||||
outputDir = file('build/classes/main')
|
||||
className = 'minetweaker.mc18.MineTweakerRegistry'
|
||||
}
|
||||
|
||||
tasks.jar.dependsOn(makeRegistry)
|
||||
|
||||
processResources
|
||||
{
|
||||
// this will ensure that this task is redone when the versions change.
|
||||
|
||||
@@ -28,8 +28,9 @@ public class ForgeEventHandler {
|
||||
minetweaker.api.event.PlayerInteractEvent event = new minetweaker.api.event.PlayerInteractEvent(
|
||||
MineTweakerMC.getIPlayer(ev.entityPlayer),
|
||||
MineTweakerMC.getDimension(ev.world),
|
||||
ev.pos.getX(), ev.pos.getY(), ev.pos.getZ()
|
||||
);
|
||||
ev.pos == null ? 0 : ev.pos.getX(),
|
||||
ev.pos == null ? 0 : ev.pos.getY(),
|
||||
ev.pos == null ? 0 : ev.pos.getZ());
|
||||
|
||||
MineTweakerImplementationAPI.events.publishPlayerInteract(event);
|
||||
}
|
||||
|
||||
@@ -153,6 +153,7 @@ public class MineTweakerMod {
|
||||
public void onServerAboutToStart(FMLServerAboutToStartEvent ev) {
|
||||
// starts before loading worlds
|
||||
// perfect place to start MineTweaker!
|
||||
ItemBracketHandler.rebuildItemRegistry();
|
||||
|
||||
if (MineTweakerPlatformUtils.isClient()) {
|
||||
MineTweakerAPI.client = new MCClient();
|
||||
|
||||
+6
-6
@@ -41,15 +41,15 @@ import com.google.common.collect.HashBiMap;
|
||||
*/
|
||||
@BracketHandler(priority = 100)
|
||||
public class ItemBracketHandler implements IBracketHandler {
|
||||
public static final BiMap<String, Item> itemNames;
|
||||
|
||||
static {
|
||||
itemNames = HashBiMap.create();
|
||||
private static final BiMap<String, Item> itemNames = HashBiMap.create();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void rebuildItemRegistry() {
|
||||
itemNames.clear();
|
||||
for (ResourceLocation itemRes : (Set<ResourceLocation>) Item.itemRegistry.getKeys()) {
|
||||
String itemName = itemRes.getResourceDomain() + ":" + itemRes.getResourcePath();
|
||||
itemNames.put(itemName.replace(" ", ""), (Item) Item.itemRegistry.getObject(itemName));
|
||||
System.out.println(itemName + " : " + (Item) Item.itemRegistry.getObject(itemName));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class ItemBracketHandler implements IBracketHandler {
|
||||
if (tokens.size() == 1 && tokens.get(0).getValue().equals("*")) {
|
||||
return symbolAny;
|
||||
}
|
||||
|
||||
|
||||
// detect special cases:
|
||||
// item: at the start means item-specific syntax
|
||||
// :xxx with xxx an integer means sub-item syntax
|
||||
|
||||
Reference in new issue
Block a user