mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-27 23:33:10 +00:00
- Added IC2 charge conditions and transformers
- Fixed 1.6.4 frantically reloading scripts - Fixed 1.7.10 chat messages
This commit is contained in:
1 parent
70cba6d84b
commit
55c3630bf3
7 files changed
+162
-3
No files matched your search
@@ -50,6 +50,8 @@ public class ScriptProviderMemory implements IScriptProvider {
|
||||
while (script.next()) {
|
||||
String name = script.getName();
|
||||
byte[] data = FileUtil.read(script.open());
|
||||
if (data.length == 0) continue; // skip empty files
|
||||
|
||||
deflaterData.writeUTF(name);
|
||||
deflaterData.writeInt(data.length);
|
||||
deflaterData.write(data);
|
||||
|
||||
+4
-2
@@ -35,8 +35,10 @@ public class MCPacketHandler implements IPacketHandler {
|
||||
if (packet.channel.equals(CHANNEL_SERVERSCRIPT)) {
|
||||
System.out.println("Received script data: " + packet.data.length + " bytes");
|
||||
|
||||
MineTweakerImplementationAPI.setScriptProvider(new ScriptProviderMemory(packet.data));
|
||||
MineTweakerImplementationAPI.reload();
|
||||
if (MineTweakerAPI.server == null) {
|
||||
MineTweakerImplementationAPI.setScriptProvider(new ScriptProviderMemory(packet.data));
|
||||
MineTweakerImplementationAPI.reload();
|
||||
}
|
||||
} else if (packet.channel.equals(CHANNEL_OPENBROWSER)) {
|
||||
String url = UTF8.decode(ByteBuffer.wrap(packet.data)).toString().trim();
|
||||
if(Desktop.isDesktopSupported()){
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.mods.ic2.expand;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemCondition;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.item.IItemTransformer;
|
||||
import stanhebben.zenscript.annotations.ZenExpansion;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenExpansion("minetweaker.item.IIngredient")
|
||||
public class IngredientExpansion {
|
||||
@ZenMethod
|
||||
public static IIngredient onlyIC2ChargeAtLeast(IIngredient ingredient, final int charge) {
|
||||
return ingredient.only(new IItemCondition() {
|
||||
@Override
|
||||
public boolean matches(IItemStack stack) {
|
||||
return ItemExpansion.getIC2Charge(stack) >= charge;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static IIngredient onlyIC2ChargeAtMost(IIngredient ingredient, final int charge) {
|
||||
return ingredient.only(new IItemCondition() {
|
||||
@Override
|
||||
public boolean matches(IItemStack stack) {
|
||||
return ItemExpansion.getIC2Charge(stack) <= charge;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static IIngredient transformIC2Discharge(IIngredient ingredient, final int amount) {
|
||||
return ingredient.transform(new IItemTransformer() {
|
||||
@Override
|
||||
public IItemStack transform(IItemStack item) {
|
||||
return ItemExpansion.ic2Discharge(item, amount, 0).withAmount(item.getAmount() + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+1
@@ -2,6 +2,7 @@ package minetweaker.mods.ic2.expand;
|
||||
|
||||
import ic2.api.item.ElectricItem;
|
||||
import ic2.api.item.IElectricItem;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.ModOnly;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class MCPlayer implements IPlayer {
|
||||
|
||||
@Override
|
||||
public void sendChat(IChatMessage message) {
|
||||
Object internal = message;
|
||||
Object internal = message.getInternal();
|
||||
if (!(internal instanceof IChatComponent)) {
|
||||
MineTweakerAPI.logError("not a valid chat message");
|
||||
return;
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.mods.ic2.expand;
|
||||
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemCondition;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.item.IItemTransformer;
|
||||
import stanhebben.zenscript.annotations.ZenExpansion;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenExpansion("minetweaker.item.IIngredient")
|
||||
public class IngredientExpansion {
|
||||
@ZenMethod
|
||||
public static IIngredient onlyIC2ChargeAtLeast(IIngredient ingredient, final int charge) {
|
||||
return ingredient.only(new IItemCondition() {
|
||||
@Override
|
||||
public boolean matches(IItemStack stack) {
|
||||
return ItemExpansion.getIC2Charge(stack) >= charge;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static IIngredient onlyIC2ChargeAtMost(IIngredient ingredient, final int charge) {
|
||||
return ingredient.only(new IItemCondition() {
|
||||
@Override
|
||||
public boolean matches(IItemStack stack) {
|
||||
return ItemExpansion.getIC2Charge(stack) <= charge;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static IIngredient transformIC2Discharge(IIngredient ingredient, final int amount) {
|
||||
return ingredient.transform(new IItemTransformer() {
|
||||
@Override
|
||||
public IItemStack transform(IItemStack item) {
|
||||
return ItemExpansion.ic2Discharge(item, amount, 0).withAmount(item.getAmount() + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.mods.ic2.expand;
|
||||
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemCondition;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.item.IItemTransformer;
|
||||
import stanhebben.zenscript.annotations.ZenExpansion;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
@ZenExpansion("minetweaker.item.IIngredient")
|
||||
public class IngredientExpansion {
|
||||
@ZenMethod
|
||||
public static IIngredient onlyIC2ChargeAtLeast(IIngredient ingredient, final int charge) {
|
||||
return ingredient.only(new IItemCondition() {
|
||||
@Override
|
||||
public boolean matches(IItemStack stack) {
|
||||
return ItemExpansion.getIC2Charge(stack) >= charge;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static IIngredient onlyIC2ChargeAtMost(IIngredient ingredient, final int charge) {
|
||||
return ingredient.only(new IItemCondition() {
|
||||
@Override
|
||||
public boolean matches(IItemStack stack) {
|
||||
return ItemExpansion.getIC2Charge(stack) <= charge;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static IIngredient transformIC2Discharge(IIngredient ingredient, final int amount) {
|
||||
return ingredient.transform(new IItemTransformer() {
|
||||
@Override
|
||||
public IItemStack transform(IItemStack item) {
|
||||
return ItemExpansion.ic2Discharge(item, amount, 0).withAmount(item.getAmount() + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user