Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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);
	}
	}
}

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.