mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-20 03:59:38 +00:00
- Fixed multiple saplings with the same ID not working in the Planter
- Fixed crash when using /mt hand on a dedicated server - Fixed crash in /mt recipes in some cases
This commit is contained in:
1 parent
59ef38877f
commit
7d886a3ce3
37 files changed
+500
-99
No files matched your search
@@ -77,22 +77,22 @@ public class DataBool implements IData {
|
||||
|
||||
@Override
|
||||
public IData getAt(int i) {
|
||||
throw new RuntimeException("a bool is not indexable");
|
||||
throw new UnsupportedOperationException("a bool is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAt(int i, IData value) {
|
||||
throw new RuntimeException("a bool is not indexable");
|
||||
throw new UnsupportedOperationException("a bool is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IData memberGet(String name) {
|
||||
throw new RuntimeException("a bool is not indexable");
|
||||
throw new UnsupportedOperationException("a bool is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void memberSet(String name, IData data) {
|
||||
throw new RuntimeException("a bool is not indexable");
|
||||
throw new UnsupportedOperationException("a bool is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,7 @@ public class DataByte implements IData {
|
||||
|
||||
@Override
|
||||
public boolean asBool() {
|
||||
throw new RuntimeException("Cannot cast a byte to a bool");
|
||||
throw new IllegalDataException("Cannot cast a byte to a bool");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,22 +77,22 @@ public class DataByte implements IData {
|
||||
|
||||
@Override
|
||||
public IData getAt(int i) {
|
||||
throw new RuntimeException("A byte is not indexable");
|
||||
throw new UnsupportedOperationException("A byte is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAt(int i, IData value) {
|
||||
throw new RuntimeException("A byte is not indexable");
|
||||
throw new UnsupportedOperationException("A byte is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IData memberGet(String name) {
|
||||
throw new RuntimeException("A byte is not indexable");
|
||||
throw new UnsupportedOperationException("A byte is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void memberSet(String name, IData data) {
|
||||
throw new RuntimeException("A byte is not indexable");
|
||||
throw new UnsupportedOperationException("A byte is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -74,51 +74,53 @@ public class DataByteArray implements IData {
|
||||
|
||||
@Override
|
||||
public boolean asBool() {
|
||||
throw new UnsupportedOperationException("Cannot cast an array to bool");
|
||||
throw new IllegalDataException("Cannot cast an array to bool");
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte asByte() {
|
||||
throw new UnsupportedOperationException("Cannot cast an array to byte");
|
||||
throw new IllegalDataException("Cannot cast an array to byte");
|
||||
}
|
||||
|
||||
@Override
|
||||
public short asShort() {
|
||||
throw new UnsupportedOperationException("Cannot cast an array to short");
|
||||
throw new IllegalDataException("Cannot cast an array to short");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int asInt() {
|
||||
throw new UnsupportedOperationException("Cannot cast an array to int");
|
||||
throw new IllegalDataException("Cannot cast an array to int");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long asLong() {
|
||||
throw new UnsupportedOperationException("Cannot cast an array to long");
|
||||
throw new IllegalDataException("Cannot cast an array to long");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float asFloat() {
|
||||
throw new UnsupportedOperationException("Cannot cast an array to float");
|
||||
throw new IllegalDataException("Cannot cast an array to float");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double asDouble() {
|
||||
throw new UnsupportedOperationException("Cannot cast an array to double");
|
||||
throw new IllegalDataException("Cannot cast an array to double");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asString() {
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append("X\"");
|
||||
result.append("[");
|
||||
boolean first = true;
|
||||
for (byte value : data) {
|
||||
String str = Integer.toHexString(value);
|
||||
if (str.length() == 1) {
|
||||
result.append('0');
|
||||
}
|
||||
result.append(str);
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
result.append(", ");
|
||||
|
||||
result.append(value);
|
||||
}
|
||||
result.append('"');
|
||||
result.append("] as byte[]");
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class DataDouble implements IData {
|
||||
|
||||
@Override
|
||||
public boolean asBool() {
|
||||
throw new RuntimeException("Cannot cast a double to a bool");
|
||||
throw new IllegalDataException("Cannot cast a double to a bool");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,22 +77,22 @@ public class DataDouble implements IData {
|
||||
|
||||
@Override
|
||||
public IData getAt(int i) {
|
||||
throw new RuntimeException("A double is not indexable");
|
||||
throw new UnsupportedOperationException("A double is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAt(int i, IData value) {
|
||||
throw new RuntimeException("A double is not indexable");
|
||||
throw new UnsupportedOperationException("A double is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IData memberGet(String name) {
|
||||
throw new RuntimeException("A double is not indexable");
|
||||
throw new UnsupportedOperationException("A double is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void memberSet(String name, IData data) {
|
||||
throw new RuntimeException("A double is not indexable");
|
||||
throw new UnsupportedOperationException("A double is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,7 @@ public class DataFloat implements IData {
|
||||
|
||||
@Override
|
||||
public boolean asBool() {
|
||||
throw new RuntimeException("Cannot cast a float to a bool");
|
||||
throw new IllegalDataException("Cannot cast a float to a bool");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,22 +77,22 @@ public class DataFloat implements IData {
|
||||
|
||||
@Override
|
||||
public IData getAt(int i) {
|
||||
throw new RuntimeException("A float is not indexable");
|
||||
throw new UnsupportedOperationException("A float is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAt(int i, IData value) {
|
||||
throw new RuntimeException("A float is not indexable");
|
||||
throw new UnsupportedOperationException("A float is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IData memberGet(String name) {
|
||||
throw new RuntimeException("A float is not indexable");
|
||||
throw new UnsupportedOperationException("A float is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void memberSet(String name, IData data) {
|
||||
throw new RuntimeException("A float is not indexable");
|
||||
throw new UnsupportedOperationException("A float is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -74,37 +74,37 @@ public class DataIntArray implements IData {
|
||||
|
||||
@Override
|
||||
public boolean asBool() {
|
||||
throw new UnsupportedOperationException("Cannot cast an array to bool");
|
||||
throw new IllegalDataException("Cannot cast an array to bool");
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte asByte() {
|
||||
throw new UnsupportedOperationException("Cannot cast an array to byte");
|
||||
throw new IllegalDataException("Cannot cast an array to byte");
|
||||
}
|
||||
|
||||
@Override
|
||||
public short asShort() {
|
||||
throw new UnsupportedOperationException("Cannot cast an array to short");
|
||||
throw new IllegalDataException("Cannot cast an array to short");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int asInt() {
|
||||
throw new UnsupportedOperationException("Cannot cast an array to int");
|
||||
throw new IllegalDataException("Cannot cast an array to int");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long asLong() {
|
||||
throw new UnsupportedOperationException("Cannot cast an array to long");
|
||||
throw new IllegalDataException("Cannot cast an array to long");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float asFloat() {
|
||||
throw new UnsupportedOperationException("Cannot cast an array to float");
|
||||
throw new IllegalDataException("Cannot cast an array to float");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double asDouble() {
|
||||
throw new UnsupportedOperationException("Cannot cast an array to double");
|
||||
throw new IllegalDataException("Cannot cast an array to double");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,37 +21,37 @@ public class DataList implements IData {
|
||||
|
||||
@Override
|
||||
public boolean asBool() {
|
||||
throw new RuntimeException("Cannot convert a list to a bool");
|
||||
throw new IllegalDataException("Cannot convert a list to a bool");
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte asByte() {
|
||||
throw new RuntimeException("Cannot convert a list to a byte");
|
||||
throw new IllegalDataException("Cannot convert a list to a byte");
|
||||
}
|
||||
|
||||
@Override
|
||||
public short asShort() {
|
||||
throw new RuntimeException("Cannot convert a list to a short");
|
||||
throw new IllegalDataException("Cannot convert a list to a short");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int asInt() {
|
||||
throw new RuntimeException("Cannot convert a list to an int");
|
||||
throw new IllegalDataException("Cannot convert a list to an int");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long asLong() {
|
||||
throw new RuntimeException("Cannot convert a list to a long");
|
||||
throw new IllegalDataException("Cannot convert a list to a long");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float asFloat() {
|
||||
throw new RuntimeException("Cannot convert a list to a float");
|
||||
throw new IllegalDataException("Cannot convert a list to a float");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double asDouble() {
|
||||
throw new RuntimeException("Cannot convert a list to a double");
|
||||
throw new IllegalDataException("Cannot convert a list to a double");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,7 +119,7 @@ public class DataList implements IData {
|
||||
@Override
|
||||
public void setAt(int i, IData value) {
|
||||
if (immutable) {
|
||||
throw new RuntimeException("this list is immutable");
|
||||
throw new UnsupportedOperationException("this list is immutable");
|
||||
} else {
|
||||
values.set(i, value);
|
||||
}
|
||||
@@ -127,12 +127,12 @@ public class DataList implements IData {
|
||||
|
||||
@Override
|
||||
public IData memberGet(String name) {
|
||||
throw new RuntimeException("Lists don't have members");
|
||||
throw new UnsupportedOperationException("Lists don't have members");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void memberSet(String name, IData data) {
|
||||
throw new RuntimeException("Lists don't have members");
|
||||
throw new UnsupportedOperationException("Lists don't have members");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,7 @@ public class DataLong implements IData {
|
||||
|
||||
@Override
|
||||
public boolean asBool() {
|
||||
throw new RuntimeException("Cannot cast a long to a bool");
|
||||
throw new IllegalDataException("Cannot cast a long to a bool");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,42 +57,42 @@ public class DataLong implements IData {
|
||||
|
||||
@Override
|
||||
public List<IData> asList() {
|
||||
throw new UnsupportedOperationException("Cannot cast a long to a list");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, IData> asMap() {
|
||||
throw new UnsupportedOperationException("Cannot cast a long to a map");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] asByteArray() {
|
||||
throw new RuntimeException("Cannot cast a long to a byte array");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] asIntArray() {
|
||||
throw new RuntimeException("Cannot cast a long to an int array");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IData getAt(int i) {
|
||||
throw new RuntimeException("A long is not indexable");
|
||||
throw new UnsupportedOperationException("A long is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAt(int i, IData value) {
|
||||
throw new RuntimeException("A long is not indexable");
|
||||
throw new UnsupportedOperationException("A long is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IData memberGet(String name) {
|
||||
throw new RuntimeException("A long is not indexable");
|
||||
throw new UnsupportedOperationException("A long is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void memberSet(String name, IData data) {
|
||||
throw new RuntimeException("A long is not indexable");
|
||||
throw new UnsupportedOperationException("A long is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,7 @@ public class DataShort implements IData {
|
||||
|
||||
@Override
|
||||
public boolean asBool() {
|
||||
throw new RuntimeException("Cannot cast a short to a bool");
|
||||
throw new IllegalDataException("Cannot cast a short to a bool");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,22 +77,22 @@ public class DataShort implements IData {
|
||||
|
||||
@Override
|
||||
public IData getAt(int i) {
|
||||
throw new RuntimeException("A short is not indexable");
|
||||
throw new UnsupportedOperationException("A short is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAt(int i, IData value) {
|
||||
throw new RuntimeException("A short is not indexable");
|
||||
throw new UnsupportedOperationException("A short is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IData memberGet(String name) {
|
||||
throw new RuntimeException("A short is not indexable");
|
||||
throw new UnsupportedOperationException("A short is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void memberSet(String name, IData data) {
|
||||
throw new RuntimeException("A short is not indexable");
|
||||
throw new UnsupportedOperationException("A short is not indexable");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -82,7 +82,7 @@ public class DataString implements IData {
|
||||
|
||||
@Override
|
||||
public void setAt(int i, IData value) {
|
||||
throw new RuntimeException("Strings are immutable");
|
||||
throw new UnsupportedOperationException("Strings are immutable");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,13 +90,13 @@ public class DataString implements IData {
|
||||
if (name.equals("length")) {
|
||||
return new DataInt(value.length());
|
||||
} else {
|
||||
throw new RuntimeException("no such member: " + name);
|
||||
throw new UnsupportedOperationException("no such member: " + name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void memberSet(String name, IData data) {
|
||||
throw new RuntimeException("Strings are immutable");
|
||||
throw new UnsupportedOperationException("Strings are immutable");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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.item;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class IngredientUnknown implements IIngredient
|
||||
{
|
||||
public static final IngredientUnknown INSTANCE = new IngredientUnknown(1);
|
||||
|
||||
private final int size;
|
||||
|
||||
public IngredientUnknown(int size)
|
||||
{
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMark()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmount()
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IItemStack> getItems()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient amount(int amount)
|
||||
{
|
||||
return new IngredientUnknown(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient or(IIngredient ingredient)
|
||||
{
|
||||
return ingredient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient transform(IItemTransformer transformer)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient only(IItemCondition condition)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient marked(String mark)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(IItemStack item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(IIngredient ingredient)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack applyTransform(IItemStack item, IPlayer byPlayer)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTransformers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInternal()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -63,4 +63,7 @@ public interface IPlayer {
|
||||
|
||||
// not an exposed method. risks abuse
|
||||
public void openBrowser(String url);
|
||||
|
||||
// not an exposed method, so far. would it be useful?
|
||||
public void copyToClipboard(String value);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.util;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class StringUtil
|
||||
{
|
||||
private static final Charset UTF8 = Charset.forName("UTF-8");
|
||||
|
||||
private StringUtil() {}
|
||||
|
||||
public static String decodeUTF8(byte[] data)
|
||||
{
|
||||
return UTF8.decode(ByteBuffer.wrap(data)).toString().trim();
|
||||
}
|
||||
|
||||
public static byte[] encodeUTF8(String data)
|
||||
{
|
||||
return UTF8.encode(data).array();
|
||||
}
|
||||
}
|
||||
@@ -140,6 +140,14 @@ public class MineTweakerMod {
|
||||
}
|
||||
}
|
||||
|
||||
public void copyToClipboard(String user, String data) {
|
||||
if (networkByUser.containsKey(user)) {
|
||||
networkByUser.get(user).addToSendQueue(new Packet250CustomPayload(
|
||||
MCPacketHandler.CHANNEL_OPENBROWSER,
|
||||
MCPacketHandler.UTF8.encode(data).array()));
|
||||
}
|
||||
}
|
||||
|
||||
// ##########################
|
||||
// ### FML Event Handlers ###
|
||||
// ##########################
|
||||
|
||||
@@ -65,4 +65,14 @@ public class MCSpecificBlock implements IBlock {
|
||||
public String getDisplayName() {
|
||||
return block.getLocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "<block:" + getBlockId(block) + ":" + (meta == OreDictionary.WILDCARD_VALUE ? '*' : meta) + ">";
|
||||
}
|
||||
|
||||
private static String getBlockId(Block block)
|
||||
{
|
||||
return block.getUnlocalizedName();
|
||||
}
|
||||
}
|
||||
+14
-1
@@ -11,6 +11,9 @@ import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
@@ -26,6 +29,7 @@ public class MCPacketHandler implements IPacketHandler {
|
||||
|
||||
public static final String CHANNEL_SERVERSCRIPT = "MTServerScript";
|
||||
public static final String CHANNEL_OPENBROWSER = "MTOpenBrowser";
|
||||
public static final String CHANNEL_COPYTOCLIPBOARD = "MTCopyToClipboard";
|
||||
|
||||
@Override
|
||||
public void onPacketData(INetworkManager manager,
|
||||
@@ -44,7 +48,8 @@ public class MCPacketHandler implements IPacketHandler {
|
||||
}
|
||||
} else if (packet.channel.equals(CHANNEL_OPENBROWSER)) {
|
||||
String url = UTF8.decode(ByteBuffer.wrap(packet.data)).toString().trim();
|
||||
if(Desktop.isDesktopSupported()){
|
||||
|
||||
if (Desktop.isDesktopSupported()){
|
||||
Desktop desktop = Desktop.getDesktop();
|
||||
try {
|
||||
desktop.browse(new URI(url));
|
||||
@@ -52,6 +57,14 @@ public class MCPacketHandler implements IPacketHandler {
|
||||
} catch (URISyntaxException e) {
|
||||
}
|
||||
}
|
||||
} else if (packet.channel.equals(CHANNEL_COPYTOCLIPBOARD)) {
|
||||
String message = UTF8.decode(ByteBuffer.wrap(packet.data)).toString().trim();
|
||||
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
StringSelection stringSelection = new StringSelection(message);
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
clipboard.setContents(stringSelection, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,6 +111,13 @@ public class MCPlayer implements IPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyToClipboard(String value) {
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
MineTweakerMod.INSTANCE.copyToClipboard(player.username, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void give(IItemStack stack) {
|
||||
player.inventory.addItemStackToInventory(MineTweakerMC.getItemStack(stack).copy());
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
package minetweaker.mc164.server;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.logging.Level;
|
||||
@@ -105,6 +108,15 @@ public class ServerPlayer implements IPlayer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyToClipboard(String value) {
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
StringSelection stringSelection = new StringSelection(value);
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
clipboard.setContents(stringSelection, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void give(IItemStack stack) {
|
||||
|
||||
@@ -134,18 +134,16 @@ public class Planter {
|
||||
return false;
|
||||
|
||||
for (TweakerPlantable plantable : plantables) {
|
||||
if (!plantable.seed.matches(MineTweakerMC.getIItemStack(seed))) {
|
||||
//System.out.println("Cannot plant (seed doesn't match)");
|
||||
return false;
|
||||
}
|
||||
if (!plantable.seed.matches(MineTweakerMC.getIItemStack(seed)))
|
||||
continue;
|
||||
|
||||
if (!plantable.canPlantOn.matches(MineTweakerMC.getBlock(world, x, y - 1, z))) {
|
||||
//System.out.println("Cannot plant (not on the right block");
|
||||
return false;
|
||||
}
|
||||
if (!plantable.canPlantOn.matches(MineTweakerMC.getBlock(world, x, y - 1, z)))
|
||||
continue;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,6 +9,7 @@ import minetweaker.api.block.IBlockDefinition;
|
||||
import minetweaker.api.data.IData;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.item.IngredientUnknown;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import minetweaker.api.oredict.IOreDictEntry;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
@@ -442,7 +443,7 @@ public class MineTweakerMC {
|
||||
IOreDictEntry entry = getOreDictEntryFromArray((List) ingredient);
|
||||
|
||||
if (entry == null) {
|
||||
throw new IllegalArgumentException("No matching oredict entry: " + ingredient);
|
||||
return IngredientUnknown.INSTANCE;
|
||||
}
|
||||
|
||||
return entry;
|
||||
|
||||
@@ -28,6 +28,8 @@ import minetweaker.mc1710.furnace.FuelTweaker;
|
||||
import minetweaker.mc1710.furnace.MCFurnaceManager;
|
||||
import minetweaker.mc1710.game.MCGame;
|
||||
import minetweaker.mc1710.mods.MCLoadedMods;
|
||||
import minetweaker.mc1710.network.MineTweakerCopyClipboardHandler;
|
||||
import minetweaker.mc1710.network.MineTweakerCopyClipboardPacket;
|
||||
import minetweaker.mc1710.network.MineTweakerLoadScriptsHandler;
|
||||
import minetweaker.mc1710.network.MineTweakerLoadScriptsPacket;
|
||||
import minetweaker.mc1710.network.MineTweakerOpenBrowserHandler;
|
||||
@@ -76,6 +78,7 @@ public class MineTweakerMod {
|
||||
static {
|
||||
NETWORK.registerMessage(MineTweakerLoadScriptsHandler.class, MineTweakerLoadScriptsPacket.class, 0, Side.CLIENT);
|
||||
NETWORK.registerMessage(MineTweakerOpenBrowserHandler.class, MineTweakerOpenBrowserPacket.class, 1, Side.CLIENT);
|
||||
NETWORK.registerMessage(MineTweakerCopyClipboardHandler.class, MineTweakerCopyClipboardPacket.class, 2, Side.CLIENT);
|
||||
}
|
||||
|
||||
@Mod.Instance(MODID)
|
||||
@@ -99,16 +102,8 @@ public class MineTweakerMod {
|
||||
MineTweakerImplementationAPI.platform = MCPlatformFunctions.INSTANCE;
|
||||
|
||||
File globalDir = new File("scripts");
|
||||
if (!globalDir.exists()) {
|
||||
if (!globalDir.exists())
|
||||
globalDir.mkdirs();
|
||||
}
|
||||
|
||||
/*try {
|
||||
String data = Resources.toString(Resources.getResource(MineTweakerMod.class, "/minetweaker/myscript.zs"), Charsets.UTF_8);
|
||||
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}*/
|
||||
|
||||
scriptsIMC = new ScriptProviderCustom("intermod");
|
||||
scriptsGlobal = new ScriptProviderDirectory(globalDir);
|
||||
|
||||
@@ -65,4 +65,14 @@ public class MCSpecificBlock implements IBlock {
|
||||
public String getDisplayName() {
|
||||
return block.getLocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "<block:" + getBlockId(block) + ":" + (meta == OreDictionary.WILDCARD_VALUE ? '*' : meta) + ">";
|
||||
}
|
||||
|
||||
private static String getBlockId(Block block)
|
||||
{
|
||||
return Block.blockRegistry.getNameForObject(block);
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.mc1710.network;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class MineTweakerCopyClipboardHandler implements IMessageHandler<MineTweakerCopyClipboardPacket, IMessage> {
|
||||
@Override
|
||||
public IMessage onMessage(MineTweakerCopyClipboardPacket message, MessageContext ctx) {
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
StringSelection stringSelection = new StringSelection(message.getData());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
clipboard.setContents(stringSelection, null);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.mc1710.network;
|
||||
|
||||
import static com.google.common.base.Charsets.UTF_8;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class MineTweakerCopyClipboardPacket implements IMessage
|
||||
{
|
||||
private String data;
|
||||
|
||||
public MineTweakerCopyClipboardPacket() {
|
||||
}
|
||||
|
||||
public MineTweakerCopyClipboardPacket(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
data = UTF_8.decode(ByteBuffer.wrap(buf.array())).toString().trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeBytes(UTF_8.encode(data).array());
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.mc1710.MineTweakerMod;
|
||||
import minetweaker.mc1710.data.NBTConverter;
|
||||
import minetweaker.mc1710.network.MineTweakerCopyClipboardPacket;
|
||||
import minetweaker.mc1710.network.MineTweakerOpenBrowserPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -114,6 +115,15 @@ public class MCPlayer implements IPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyToClipboard(String value) {
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
MineTweakerMod.NETWORK.sendTo(
|
||||
new MineTweakerCopyClipboardPacket(value),
|
||||
(EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other.getClass() != this.getClass())
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
package minetweaker.mc1710.server;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.logging.Level;
|
||||
@@ -106,6 +109,15 @@ public class ServerPlayer implements IPlayer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyToClipboard(String value) {
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
StringSelection stringSelection = new StringSelection(value);
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
clipboard.setContents(stringSelection, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void give(IItemStack stack) {
|
||||
|
||||
@@ -30,7 +30,7 @@ dependencies {
|
||||
compile project(':ZenScript')
|
||||
compile project(':MineTweaker3-API')
|
||||
compile project(':MineTweaker3-MC1710-Main')
|
||||
compile files('libs/gregtech-1.7.10-dev.jar')
|
||||
compile files('libs/gregtech_1.7.10-5.05.11-dev.jar')
|
||||
}
|
||||
|
||||
task makeRegistry(type: RegisterZenClassesTask) {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+5
-2
@@ -117,7 +117,8 @@ public class Harvester {
|
||||
public HarvestType getHarvestType() {
|
||||
// WARNING: first type will be used
|
||||
// Also, take into account the possibility of having no harvestable yet
|
||||
return harvestables.isEmpty() ? HarvestType.Normal : harvestables.get(0).type;
|
||||
HarvestType result = harvestables.isEmpty() ? HarvestType.Normal : harvestables.get(0).type;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -127,8 +128,10 @@ public class Harvester {
|
||||
|
||||
@Override
|
||||
public boolean canBeHarvested(World world, Map<String, Boolean> map, int x, int y, int z) {
|
||||
IBlock block = MineTweakerMC.getBlock(world, x, y, z);
|
||||
|
||||
for (TweakerHarvestable harvestable : harvestables) {
|
||||
if (harvestable.block.matches(MineTweakerMC.getBlock(world, x, y, z)))
|
||||
if (harvestable.block.matches(block))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+7
-9
@@ -135,18 +135,16 @@ public class Planter {
|
||||
return false;
|
||||
|
||||
for (TweakerPlantable plantable : plantables) {
|
||||
if (!plantable.seed.matches(MineTweakerMC.getIItemStack(seed))) {
|
||||
//System.out.println("Cannot plant (seed doesn't match)");
|
||||
return false;
|
||||
}
|
||||
if (!plantable.seed.matches(MineTweakerMC.getIItemStack(seed)))
|
||||
continue;
|
||||
|
||||
if (!plantable.canPlantOn.matches(MineTweakerMC.getBlock(world, x, y - 1, z))) {
|
||||
//System.out.println("Cannot plant (not on the right block");
|
||||
return false;
|
||||
}
|
||||
if (!plantable.canPlantOn.matches(MineTweakerMC.getBlock(world, x, y - 1, z)))
|
||||
continue;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,6 +27,8 @@ import minetweaker.mc172.furnace.FuelTweaker;
|
||||
import minetweaker.mc172.furnace.MCFurnaceManager;
|
||||
import minetweaker.mc172.game.MCGame;
|
||||
import minetweaker.mc172.mods.MCLoadedMods;
|
||||
import minetweaker.mc172.network.MineTweakerCopyClipboardHandler;
|
||||
import minetweaker.mc172.network.MineTweakerCopyClipboardPacket;
|
||||
import minetweaker.mc172.network.MineTweakerLoadScriptsHandler;
|
||||
import minetweaker.mc172.network.MineTweakerLoadScriptsPacket;
|
||||
import minetweaker.mc172.network.MineTweakerOpenBrowserHandler;
|
||||
@@ -72,6 +74,7 @@ public class MineTweakerMod {
|
||||
static {
|
||||
NETWORK.registerMessage(MineTweakerLoadScriptsHandler.class, MineTweakerLoadScriptsPacket.class, 0, Side.CLIENT);
|
||||
NETWORK.registerMessage(MineTweakerOpenBrowserHandler.class, MineTweakerOpenBrowserPacket.class, 1, Side.CLIENT);
|
||||
NETWORK.registerMessage(MineTweakerCopyClipboardHandler.class, MineTweakerCopyClipboardPacket.class, 2, Side.CLIENT);
|
||||
}
|
||||
|
||||
@Mod.Instance(MODID)
|
||||
|
||||
@@ -65,4 +65,14 @@ public class MCSpecificBlock implements IBlock {
|
||||
public String getDisplayName() {
|
||||
return block.getLocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "<block:" + getBlockId(block) + ":" + (meta == OreDictionary.WILDCARD_VALUE ? '*' : meta) + ">";
|
||||
}
|
||||
|
||||
private static String getBlockId(Block block)
|
||||
{
|
||||
return Block.blockRegistry.getNameForObject(block);
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.mc172.network;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class MineTweakerCopyClipboardHandler implements IMessageHandler<MineTweakerCopyClipboardPacket, IMessage> {
|
||||
@Override
|
||||
public IMessage onMessage(MineTweakerCopyClipboardPacket message, MessageContext ctx) {
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
StringSelection stringSelection = new StringSelection(message.getData());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
clipboard.setContents(stringSelection, null);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.mc172.network;
|
||||
|
||||
import static com.google.common.base.Charsets.UTF_8;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class MineTweakerCopyClipboardPacket implements IMessage
|
||||
{
|
||||
private String data;
|
||||
|
||||
public MineTweakerCopyClipboardPacket() {
|
||||
}
|
||||
|
||||
public MineTweakerCopyClipboardPacket(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
data = UTF_8.decode(ByteBuffer.wrap(buf.array())).toString().trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeBytes(UTF_8.encode(data).array());
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.mc172.MineTweakerMod;
|
||||
import minetweaker.mc172.data.NBTConverter;
|
||||
import minetweaker.mc172.network.MineTweakerCopyClipboardPacket;
|
||||
import minetweaker.mc172.network.MineTweakerOpenBrowserPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -114,6 +115,15 @@ public class MCPlayer implements IPlayer {
|
||||
(EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyToClipboard(String value) {
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
MineTweakerMod.NETWORK.sendTo(
|
||||
new MineTweakerCopyClipboardPacket(value),
|
||||
(EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void give(IItemStack stack) {
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
package minetweaker.mc172.server;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.logging.Level;
|
||||
@@ -106,6 +109,15 @@ public class ServerPlayer implements IPlayer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyToClipboard(String value) {
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
StringSelection stringSelection = new StringSelection(value);
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
clipboard.setContents(stringSelection, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void give(IItemStack stack) {
|
||||
|
||||
Reference in new issue
Block a user