Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.7.10] For loop is broken


jackmano
 Share

Recommended Posts

My for loop wont start!

No crash, it just doesn;t go

package com.rabidfox.syntheticgems;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
public class TileHydroTorch extends TileEntity {
Random rdm = new Random();
Boolean on = false;
Boolean fire = false;	
Boolean ready = false;
Item returncrystal = null;
List crystaltypes;
List resultcrystals;
public TileHydroTorch(){
	crystaltypes = new ArrayList();
	resultcrystals = new ArrayList();
	crystaltypes.add(0, Items.blaze_powder);
	resultcrystals.add(0, Items.blaze_rod);
}
public int getFacing() {
	return 0;

}

@Override
public void writeToNBT(NBTTagCompound nbt){
	super.writeToNBT(nbt);
	nbt.setBoolean("on", on);
	nbt.setBoolean("fire", fire);
	nbt.setBoolean("ready", ready);
	nbt.setInteger("returncrystal", Item.getIdFromItem(returncrystal));
}
public void readFromNBT(NBTTagCompound nbt){
	super.readFromNBT(nbt);
	on = nbt.getBoolean("on");
	fire = nbt.getBoolean("fire");
	ready = nbt.getBoolean("ready");
	returncrystal = Item.getItemById(nbt.getInteger("returncrystal"));


}
public void igniteTorch(){
	if(on){
		fire = true;
		worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); // Makes the server call getDescriptionPacket for a full data sync
	}
}
public void turnOn(){
	if(!on){
		on = true;
		worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); // Makes the server call getDescriptionPacket for a full data sync
	}
}
public void killTorch(){
	if(fire){
		fire = false;
		worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); // Makes the server call getDescriptionPacket for a full data sync
	}
}
public void turnOff(){
	if(on){
		on = false;
		worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); // Makes the server call getDescriptionPacket for a full data sync
	}
}
    @Override
    public Packet getDescriptionPacket()
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        writeToNBT(nbttagcompound);
        return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound);
    }
    
    @Override
    public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
    {
        readFromNBT(packet.func_148857_g());
        worldObj.func_147479_m(xCoord, yCoord, zCoord);
    }
    public void activate(){
    	if(this.on){
    		this.fire = true;
    	}
    	System.out.println("Activated");
    	if(worldObj.getTileEntity(xCoord, yCoord + 1, zCoord) instanceof TileEntityChest){
        	System.out.println("Chest detected");
		int slot = 420;
    		TileEntityChest chest = (TileEntityChest)worldObj.getTileEntity(xCoord, yCoord + 1, zCoord);
        	System.out.println("tile getted");
    		for(int i = 29; i == -1; i--){
    	    	System.out.println("for");
    			Item theitem = chest.getStackInSlot(i).getItem();
    			if(theitem != null){
    		    	System.out.println("items not null");
    				if(crystaltypes.contains(theitem)){
    				    int index = crystaltypes.indexOf(theitem);
    				    this.returncrystal = (Item)resultcrystals.get(index);
    			    	System.out.println("set some shit");
    					slot = i;
    				}
    			}
    		}
    		if(!this.on && slot != 420 && RabidFoxUtil.searchChestForItem(SyntheticGems.itemoxybottle, chest) != -1 && RabidFoxUtil.searchChestForItem(SyntheticGems.itemhydbottle, chest) != -1){
    			chest.getStackInSlot(RabidFoxUtil.searchChestForItem(SyntheticGems.itemoxybottle, chest)).stackSize--;
    			chest.getStackInSlot(RabidFoxUtil.searchChestForItem(SyntheticGems.itemhydbottle, chest)).stackSize--;
    	    	System.out.println("deleted some stuff");
    			chest.getStackInSlot(slot).stackSize--;
    			this.on = true;
    		}
    	}
    }
@Override
public void updateEntity(){
		if(on && !fire){
			this.worldObj.spawnParticle("cloud", 0.5F + (worldObj.rand.nextFloat() / 5), 0.75F, 0.5F + (worldObj.rand.nextFloat() / 5), 0, -0.2F, 0);
		}
		if(on && fire){
			this.worldObj.spawnParticle("flame", 0.5F + (worldObj.rand.nextFloat() / 5), 0.75F, 0.5F + (worldObj.rand.nextFloat() / 5), 0, -0.5F, 0);
	}
	}
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.