This is one HUGELLY Helpfull mod and hope it gets the Credit due, and the 1.1.0update is the one i've been waitin for coz it's enoying that i cant go to 1.1.0 unless i whant to spend days gettan stuff for buildings and sutch.
Great mod :biggrin.gif:
Only problem, when in multiplayer I select an item and it says selected enchantment can not be made to this item. It will not allow me to put stuff in my inventory :/ any suggestions?
I'm trying to find a way to make Connected Destruction compatible with TMI for 1.1.0... I peeked at your code and see that TMI replaces the PlayerController object during initialization, which kills Connected Destruction since it uses it's own extended versions of the PlayerController class. Got any ideas on how we can work around this?
The code:
mod_connectedDestruction.java
package net.minecraft.src;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import net.minecraft.client.Minecraft;
public class mod_connectedDestruction extends BaseModMp{
public String getVersion() {
return "0.3a";
}
public void load() {
}
public mod_connectedDestruction(){
ModLoader.SetInGameHook(this, true, true);
pct = PlayerControllerType.UNKNOWN;
}
@Override
public boolean OnTickInGame(float f, Minecraft minecraft){
if(blockGroups == null) blockGroups = stringToGroups(mod_connectedDestruction.blocks);
if(getType(minecraft.playerController).equals(pct)) return true;
pct = getType(minecraft.playerController);
switch(pct){
case SURVIVAL:
minecraft.playerController = new ConnectedDestructionSP(minecraft);
break;
case CREATIVE:
minecraft.playerController = new ConnectedDestructionCreative(minecraft);
break;
case MULTIPLAYER:
try {
NetClientHandler nch = (NetClientHandler)ModLoader.getPrivateValue(PlayerControllerMP.class, minecraft.playerController, 9);
minecraft.playerController = new ConnectedDestructionMP(minecraft, nch);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
return true;
}
public PlayerControllerType getType(PlayerController pc){
if(pc instanceof PlayerControllerSP){
return PlayerControllerType.SURVIVAL;
}
if(pc instanceof PlayerControllerCreative){
return PlayerControllerType.CREATIVE;
}
if(pc instanceof PlayerControllerMP){
return PlayerControllerType.MULTIPLAYER;
}
return PlayerControllerType.UNKNOWN;
}
public boolean isIDInList(String list, int id, int metadata){
String[] itemArray = list.split(";");
for(int i = 0; i < itemArray.length; i++){
String[] values = itemArray[i].split(",");
int tempID = parseInt(values[0]);
if(values.length > 1 && parseInt(values[1]) == metadata) return true;
else if(tempID == id) return true;
}
return false;
}
private int parseInt(String string){
int res = 0;
try{
res = Integer.parseInt(string.trim());
}
catch(NumberFormatException e){
ModLoader.getLogger().log(Level.WARNING, "Invalid number format in string " + string);
}
return res;
}
public int[][][] stringToGroups(String string){
List<int[][]> groupList = new ArrayList<int[][]>();
String[] groups = string.split(";");
for(String group: groups){
groupList.add(stringToGroup(group));
}
int[][][] res = new int[groupList.size()][][];
for(int i = 0; i < groupList.size(); i++){
res[i] = groupList.get(i);
}
return res;
}
public int[][] stringToGroup(String string){
List<int[]> blockList = new ArrayList<int[]>();
String[] blocks = string.split(">");
for(String block: blocks){
blockList.add(stringToBlock(block));
}
int[][] res = new int[blockList.size()][];
for(int i = 0; i < blockList.size(); i++){
res[i] = blockList.get(i);
}
return res;
}
public int[] stringToBlock(String string){
int[] values = new int[]{0, -1};
String[] src = string.split(",");
if(src.length < 1)
return values;
values[0] = parseInt(src[0]);
if(src.length < 2)
return values;
values[1] = parseInt(src[1]);
return values;
}
public boolean isBlockInGroups(int[] block, int[][][] groups){
for(int[][] group: groups){
if(indexOfBlock(block, group) > -1)
return true;
}
return false;
}
public int indexOfBlock(int[] block, int[][] group){
for(int i = 0; i < group.length; i++){
if(block[0] == group[i][0]){
if(group[i][1] == -1 || block[1] == group[i][1]) return i;
}
}
return -1;
}
public int[][] getRelatedBlocks(int[] block, int[][][] groups){
List<int[]> blockList = new ArrayList<int[]>();
for(int[][] group: groups){
if(indexOfBlock(block, group) > -1){
for(int i = 0; i < groups.length; i++){
if(blockList.contains(group[i])) continue;
blockList.add(i, group[i]);
}
}
}
int[][] secondary = new int[blockList.size()][];
for(int i = 0; i < blockList.size(); i++){
secondary[i] = blockList.get(i);
}
return secondary;
}
public int smallerBlockIndex(int[] block, int[][][] groups){
int min = Integer.MAX_VALUE;
for(int[][] group: groups){
int i = indexOfBlock(block, group);
if(i > -1 && i < min) min = i;
}
if(min == Integer.MAX_VALUE) min = -1;
return min;
}
public boolean isMetadataNull(int id, int[][][] groups) {
for(int[][] group: groups){
for(int[] block: group){
if(block[0] == id && block[1] == -1) return true;
}
}
return false;
}
@MLProp(info="\nBlock List, \';\' splits blocks and \',\' splits block ID and metadata.")
public static String blocks = "17";
@MLProp(info="\n0-No drops.\t1-Drops in all modes but Creative.\t2-Drops in all modes.")
public static byte drops = 1;
@MLProp(info="\nLimit of blocks to be destroyed at once. Use -1 for infinite.")
public static int blockLimit = 800;
@MLProp(info="\nMaximum distance from the player to search blocks to destroy. Use -1 for infinite.")
public static int maximumDistance = 32;
@MLProp(info="\nMaximum number of blocks to be removed per game tick (1/20 seconds). Using a low number will keep the game from getting huge performance drops but also decreases the speed of which things are destroyed.\n\n**ONLY EDIT WHAT IS BELOW THIS**")
public static int blocksPerTick = 50;
public int[][][] blockGroups;
private PlayerControllerType pct;
public static mod_connectedDestruction instance = new mod_connectedDestruction();
public enum PlayerControllerType {
SURVIVAL, CREATIVE, MULTIPLAYER, UNKNOWN
};
}
ConnectedDestruction.java
package net.minecraft.src;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
public class ConnectedDestruction{
private final int LIMIT = mod_connectedDestruction.blockLimit;
private final int SCHEDULED_LIMIT = 20;
private final int MAX_DISTANCE = mod_connectedDestruction.maximumDistance;
private final int BLOCKS_PER_TICK = mod_connectedDestruction.blocksPerTick;
public int blocksHarvested;
private boolean enableDrops;
private List scheduledBlocks = new ArrayList();
private boolean firstCount;
private int initial_x, initial_y, initial_z;
private int[] block;
public ConnectedDestruction(int[] block, int x, int y, int z, boolean enableDrops) {
ModLoader.SetInGameHook(this.new TickHelper(), true, true);
this.enableDrops = enableDrops;
blocksHarvested = 0;
scheduledBlocks = new ArrayList();
this.block = block;
initial_x = x;
initial_y = y;
initial_z = z;
firstCount = true;
// System.out.println("secondary blocks: " + iterate(blocks));
}
private String iterate(int[][] group){
String res = "";
for(int[] block: group){
res = res.concat(Integer.toString(block[0])).concat(", ").concat(Integer.toString(block[1])).concat("; ");
}
return res;
}
public void harvestConnectedBlocks(World world, int x, int y, int z) {
byte d = 1;
for(int dx = -d; dx <= d; dx++){
for(int dy = -d; dy <= d; dy++){
for(int dz = -d; dz <= d; dz++){
if(dx == 0 && dy == 0 && dz == 0) continue;
int[] blockPos = new int[]{x + dx, y + dy, z + dz};
int blockID = world.getBlockId(blockPos[0], blockPos[1], blockPos[2]);
int blockMetadata = world.getBlockMetadata(blockPos[0], blockPos[1], blockPos[2]);
if(blockID == block[0] && (block[1] == -1 || block[1] == blockMetadata)){
Block block = Block.blocksList[blockID];
if(block == null) continue;
world.setBlockWithNotify(blockPos[0], blockPos[1], blockPos[2], 0);
if(enableDrops) block.dropBlockAsItem(world, initial_x, initial_y, initial_z, blockMetadata, 0);
blocksHarvested++;
if((LIMIT == -1 || blocksHarvested <= LIMIT) || (MAX_DISTANCE == -1 || getCubicDistance(blockPos[0], blockPos[1], blockPos[2]) <= MAX_DISTANCE)){
if(!scheduledBlocks.contains(blockPos))
scheduledBlocks.add(blockPos);
}
}
}
}
}
}
private int getCubicDistance(int x, int y, int z){
return Math.max(Math.abs(x - initial_x), Math.max(Math.abs(y - initial_y), Math.abs(z - initial_z)));
}
private int getDistance(int x, int y, int z) {
return Math.abs(x - initial_x) + Math.abs(y - initial_y) + Math.abs(z - initial_z);
}
private List<Integer[]> destroyScheduledBlocks(List scheduledBlocks, World world){
int removed = 0;
while(scheduledBlocks.size() > 0 && removed < BLOCKS_PER_TICK){
int[] blockPos = (int[])scheduledBlocks.remove(0);
removed++;
int[] block = new int[]{
world.getBlockId(blockPos[0], blockPos[1], blockPos[2]),
world.getBlockMetadata(blockPos[0], blockPos[1], blockPos[2])
};
harvestConnectedBlocks(world, blockPos[0], blockPos[1], blockPos[2]);
}
return scheduledBlocks;
}
private class TickHelper extends BaseMod{
public String getVersion() {
return null;
}
public void load() {}
public boolean OnTickInGame(float f, Minecraft minecraft){
if(scheduledBlocks.size() > 0){
destroyScheduledBlocks(scheduledBlocks, minecraft.theWorld);
return true;
}
return false;
}
}
}
ConnectedDestructionSP.java
package net.minecraft.src;
import net.minecraft.client.Minecraft;
public class ConnectedDestructionSP extends PlayerControllerSP {
public ConnectedDestructionSP(Minecraft minecraft) {
super(minecraft);
}
public boolean onPlayerDestroyBlock(int i, int j, int k, int l)
{
int id = mc.theWorld.getBlockId(i, j, k);
int md = mc.theWorld.getBlockMetadata(i, j, k);
Block block = Block.blocksList[id];
boolean flag = super.onPlayerDestroyBlock(i, j, k, l);
if(flag && mod_connectedDestruction.instance.isBlockInGroups(new int[]{id, md}, mod_connectedDestruction.instance.blockGroups)){
// System.out.println("Id to destroy: " + id);
if(mod_connectedDestruction.instance.isMetadataNull(id, mod_connectedDestruction.instance.blockGroups)) md = -1;
ConnectedDestruction cd = new ConnectedDestruction(new int[]{id, md}, i, j, k, mod_connectedDestruction.drops > 0);
cd.harvestConnectedBlocks(mc.theWorld, i, j, k);
}
return flag;
}
}
The Meaning of Life, the Universe, and Everything.
Join Date:
9/24/2011
Posts:
270
Minecraft:
TheMysticalBard
Member Details
When I go to my page 4 it crashes with this error in the TMI error log:
TMI Version: 1.1 2012-01-12a
java.lang.IllegalStateException: Already tesselating!
at aby.a(Tessellator.java:213)
at aby.b(Tessellator.java:206)
at su.a(RenderItem.java:390)
at su.a(RenderItem.java:276)
at su.a(RenderItem.java:288)
at _tmi_MgCanvas.drawItem(_tmi_MgCanvas.java:150)
at _tmi_MgItemPanel.draw(_tmi_MgItemPanel.java:63)
at _tmi_MgCanvas.drawWidgets(_tmi_MgCanvas.java:173)
at TMIController.onEnterFrame(TMIController.java:69)
at ft.a(ft.java:80)
at agi.a(SourceFile:51)
at kz.b(EntityRenderer.java:991)
at EntityRendererProxy.b(EntityRendererProxy.java:15)
at net.minecraft.client.Minecraft.x(SourceFile:742)
at net.minecraft.client.Minecraft.run(SourceFile:662)
at java.lang.Thread.run(Unknown Source)
When I go to my page 4 it crashes with this error in the TMI error log:
TMI Version: 1.1 2012-01-12a
java.lang.IllegalStateException: Already tesselating!
at aby.a(Tessellator.java:213)
at aby.b(Tessellator.java:206)
at su.a(RenderItem.java:390)
at su.a(RenderItem.java:276)
at su.a(RenderItem.java:288)
at _tmi_MgCanvas.drawItem(_tmi_MgCanvas.java:150)
at _tmi_MgItemPanel.draw(_tmi_MgItemPanel.java:63)
at _tmi_MgCanvas.drawWidgets(_tmi_MgCanvas.java:173)
at TMIController.onEnterFrame(TMIController.java:69)
at ft.a(ft.java:80)
at agi.a(SourceFile:51)
at kz.b(EntityRenderer.java:991)
at EntityRendererProxy.b(EntityRendererProxy.java:15)
at net.minecraft.client.Minecraft.x(SourceFile:742)
at net.minecraft.client.Minecraft.run(SourceFile:662)
at java.lang.Thread.run(Unknown Source)
Why is no one replying to all these unanswered questions?
Marglyph updates fast, very fast indeed, but he won't reply for things that are answered / explained in the OP, things already answered in the thread and things that was already fixed.
That's why :wink.gif:
Maybe someone else could help, let's see. :smile.gif:
Marglyph updates fast, very fast indeed, but he won't reply for things that are answered / explained in the OP, things already answered in the thread and things that was already fixed.
That's why :wink.gif:
Maybe someone else could help, let's see. :smile.gif:
I don't see my problem answered anywhere in the OP.....
I'd like to suggest I change in the multiplayer support.
Instead of right-clicking spawning one of the item straight away, it should instead put a number on the item you're spawning, which will increment every time you right-click, then when you either move your cursor off the item, or don't right-click for a few seconds, it will then spawn the amount of that item in one go.
For example, to spawn ten TNT, instead of it doing "/give player 46 1" ten times, it would do "/give player 46 10" once.
This would mean that there is less spam in the server's chatbox, and means you won't get yourself autokicked for command spamming.
Great mod :biggrin.gif:
Only problem, when in multiplayer I select an item and it says selected enchantment can not be made to this item. It will not allow me to put stuff in my inventory :/ any suggestions?
If you are using essentials on bukkit, go to the config and change it from "/give {0} {1} {2} {3}" to "/i {1}:{3} {2}", and it should work assuming you have the proper permissions.
When I go to my page 4 it crashes with this error in the TMI error log:
TMI Version: 1.1 2012-01-12a
java.lang.IllegalStateException: Already tesselating!
at aby.a(Tessellator.java:213)
at aby.b(Tessellator.java:206)
at su.a(RenderItem.java:390)
at su.a(RenderItem.java:276)
at su.a(RenderItem.java:288)
at _tmi_MgCanvas.drawItem(_tmi_MgCanvas.java:150)
at _tmi_MgItemPanel.draw(_tmi_MgItemPanel.java:63)
at _tmi_MgCanvas.drawWidgets(_tmi_MgCanvas.java:173)
at TMIController.onEnterFrame(TMIController.java:69)
at ft.a(ft.java:80)
at agi.a(SourceFile:51)
at kz.b(EntityRenderer.java:991)
at EntityRendererProxy.b(EntityRendererProxy.java:15)
at net.minecraft.client.Minecraft.x(SourceFile:742)
at net.minecraft.client.Minecraft.run(SourceFile:662)
at java.lang.Thread.run(Unknown Source)
Could someone please help?
I also have this problem, and haven't found anything about it. It's annoying scrolling through 16 pages of mod items only to see that the one I need is on page 4 :|
Cool Mod Ceep it up.
PLZ HELP ME!
Is their a way to disable it in just survival mode?
Press "o".
Only problem, when in multiplayer I select an item and it says selected enchantment can not be made to this item. It will not allow me to put stuff in my inventory :/ any suggestions?
The code:
mod_connectedDestruction.java
But I did try it out before that, very happy.
*facepalm*
99% mods works with tmi
SHUDDUP UPDATE TROLLS OR I MAKE U ALL TAKE AN ARROW TO THE KNEE!
http://strt.cc/?ref=ZGVhdGhseWFuZ2VsNDdAZ21haWwuY29t
Why is no one replying to all these unanswered questions?
http://strt.cc/?ref=ZGVhdGhseWFuZ2VsNDdAZ21haWwuY29t
Marglyph updates fast, very fast indeed, but he won't reply for things that are answered / explained in the OP, things already answered in the thread and things that was already fixed.
That's why :wink.gif:
Maybe someone else could help, let's see. :smile.gif:
I don't see my problem answered anywhere in the OP.....
http://strt.cc/?ref=ZGVhdGhseWFuZ2VsNDdAZ21haWwuY29t
Nevermind, I installed NEI instead.
Instead of right-clicking spawning one of the item straight away, it should instead put a number on the item you're spawning, which will increment every time you right-click, then when you either move your cursor off the item, or don't right-click for a few seconds, it will then spawn the amount of that item in one go.
For example, to spawn ten TNT, instead of it doing "/give player 46 1" ten times, it would do "/give player 46 10" once.
This would mean that there is less spam in the server's chatbox, and means you won't get yourself autokicked for command spamming.
If you are using essentials on bukkit, go to the config and change it from "/give {0} {1} {2} {3}" to "/i {1}:{3} {2}", and it should work assuming you have the proper permissions.
I also have this problem, and haven't found anything about it. It's annoying scrolling through 16 pages of mod items only to see that the one I need is on page 4 :|
I aprecate it more than you think.