Jump to content

Lua

Members
  • Posts

    191
  • Joined

  • Last visited

Everything posted by Lua

  1. I havent tested this, but in theory, this should work right? An easy way to replace the main menu would be running a tickhandler and checking for that gui and showing yours up instead
  2. I tried setting the metadata like that before i made this topic. However, using a combination of setting it and using getBlockMetadata() instead seemed to solve the problem. Thanks
  3. Still does the same thing Metadata is client sided and it prints out client side
  4. Hi, so I have a cannon which works perfectly fine, reloading, firing all that jazz. However when I leave the game and join back, the cannon 'forgets' its direction. So I thought simple fix, ill just save the meta to the TileEntity ntb methods, so I did, but no avail. So in short, the cannons fires in a position according to its direction after re-opening the game it forgets that direction(meta) and defaults to -1 (tileentites default) which makes it not go through with the else-if statement, causing it not to spawn. Bad times. Anyway, heres my code: package arcticraft.tile_entities; import net.minecraft.client.Minecraft; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import arcticraft.entities.AC_EntityCannonball; public class AC_TileEntityCannon extends TileEntity { //private int this.blockMetadata = this.blockMetadata; public boolean isLoaded; private int fuse; public AC_TileEntityCannon() { } @Override public void updateEntity() { System.out.println(this.blockMetadata); if(isLoaded) { fuse++; if(fuse == 100) { AC_EntityCannonball cannonball = new AC_EntityCannonball(worldObj, this.xCoord, this.yCoord, this.zCoord); if(this.blockMetadata == 4) { cannonball.setPosition(this.xCoord, this.yCoord + 2, this.zCoord + 2); cannonball.setVelocity(0, 2.0, 0.7); Minecraft.getMinecraft().sndManager.playSoundFX("ac:misc.cannon", 1.5F, 1.5F); worldObj.spawnEntityInWorld(cannonball); isLoaded = false; fuse = 0; } else if(this.blockMetadata == 3) { cannonball.setPosition(this.xCoord + 1.5, this.yCoord + 2, this.zCoord - 1); cannonball.setVelocity(0.625, 2.0, 0.025); Minecraft.getMinecraft().sndManager.playSoundFX("ac:misc.cannon", 1.5F, 1.5F); worldObj.spawnEntityInWorld(cannonball); isLoaded = false; fuse = 0; } else if(this.blockMetadata == 2) { cannonball.setPosition(this.xCoord, this.yCoord + 2, this.zCoord - 1); cannonball.setVelocity(0, 2.0, - 0.7); Minecraft.getMinecraft().sndManager.playSoundFX("ac:misc.cannon", 1.5F, 1.5F); worldObj.spawnEntityInWorld(cannonball); isLoaded = false; fuse = 0; } else if(this.blockMetadata == 1) { cannonball.setPosition(this.xCoord - 1.5, this.yCoord + 2, this.zCoord + 1); cannonball.setVelocity(- 0.625, 2.0, - 0.025); Minecraft.getMinecraft().sndManager.playSoundFX("ac:misc.cannon", 1.5F, 1.5F); worldObj.spawnEntityInWorld(cannonball); isLoaded = false; fuse = 0; } } } } @Override public void readFromNBT(NBTTagCompound compound) { compound.getBoolean("loaded"); compound.getInteger("fuse"); compound.getInteger("meta"); } public void writeToNBT(NBTTagCompound compound) { compound.setBoolean("loaded", isLoaded); compound.setInteger("fuse", fuse); compound.setInteger("meta", this.blockMetadata); } } On re-entering the game I see that the System.out.println(this.blockMetadata) varies between the real direction and -1. But when I first place the cannon its a sold printing of the actual direction. *To the people who try get me to tidy my code by placing the spawning of the cannonball and resetting of the fuse and stuff by putting it at the end of the else-if statement. No, because I want it to spawn depending on that meta only, as the positions and velocity correspond to that direction* Thanks ~ Ben P.S Why does using code tags mess up the formatting of your code, its annoying.
  5. Last bump
  6. nobody?
  7. le bump
  8. Can you paste your main class because I want to see if you registered the renderer before you actually initialized the item which would cause an NPE
  9. Hey I have two problems, both very weird. 1) I have a custom arrow(basically copypasta from vanilla arrow) but it has buggy movement, like when I fire it, it will fire, hit something, then move a block back. Its probably a client/server issue(but isnt position handled by client?) or the way I register it. I dont think you need to see my code cos its copypasta but if you want it, ask. But here is how I register it : EntityRegistry.registerModEntity(AC_EntityIceShard.class, "IceShard", 5, MainRegistry.instance, 128, 10, true); and heres a picture on how it looks: 2) The icon texture on my custom furnace is backwards, no idea how to fix. heres the block code, if you need any more, ask. screenshot:
  10. You can world.scheduleBlockUpdate(args) , so yes. Never knew that was such a thing, this works fine. Thanks
  11. Question 1: Is there an alternative to tick handlers? I have a block and something happens to it after a certain amount of time and id usually use a tick counter to time and then execute but id need to make the variable a static one to make it accessible from my Block class, now I dont want that because I dont want the timer to be the same for every block. Is there a way around this or an alternative? Im trying to avoid static at all costs *To people who suggest the update method in Block, it dosent tick enough, so no.*
  12. Ive made a gui w/ a textfield and when you enter the unlocalizedname of an item or a block, you receive it. However, it currently does not have metadata or amount support. Ive got an idea on how to do this but ive faced some problems. Id like to get the first 2 digit number then pass that into an int then I can just pass that into the sending of the item and then the next two digit number, id pass that as the metadata. But Im not sure how to get the get two numbers, then ensure theres a space before collecting the other two. So I guess the question is, how can I add some sort of syntax to the textbox, like it has to be in this order or it wont work(name:amount:metadata) and how can I pull the numbers from it? Im sorry if that sounds a bit confusing, dont know how to word it aha. Heres my code: package simplecamping; import java.util.ArrayList; import net.minecraft.block.Block; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.item.Item; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.util.ResourceLocation; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.network.PacketDispatcher; public class GuiScribblenauts extends GuiScreen { private GuiTextField textfield; public static Block getBlockToSend; public static Item getItemToSend; public static String thingToSend = "NAME:AMOUNT:DATAVALUE"; static String name = thingToSend.split("\\:")[0]; static String amount = thingToSend.split("\\:")[1]; static String datavalue = thingToSend.split("\\:")[2]; @Override public void initGui() { buttonList = new ArrayList(); buttonList.add(new GuiButton(1, width / 2 - 49, height / 2 + 40, 70, 20, "Enter")); textfield = new GuiTextField(fontRenderer, width / 2 - 87, height / 2 - 10, 200, 20); //textfield.setText("NAME:AMOUNT:METADATA/DAMAGEVALUE"); //so, we'd check the stuff up to the first : then apply that as the name and do the stuff w/ the others } @Override public void actionPerformed(GuiButton button) { if(button.id == 1) { for(final Block b : Block.blocksList) { if(b == null) { continue; } String s = b.getLocalizedName().replaceAll(" ", "").toLowerCase(); if(textfield.getText().toLowerCase().contains(s.toLowerCase())) { getBlockToSend = b; System.out.println("Spawning Block: " + s + " Block id: " + (b.blockID)); } } } for(final Item i : Item.itemsList) { if(i == null) { continue; } String s1 = i.getUnlocalizedName().replace("item.", "").replace("_", "").toLowerCase(); if(textfield.getText().toLowerCase().contains(s1.toLowerCase())) { getItemToSend = i; System.out.println("Spawning: " + s1 + "Item id: " + (i.itemID - 256)); } } PacketDispatcher.sendPacketToServer(new Packet250CustomPayload(Reference.SEND_ITEM_PACKET, new byte[] {1})); } protected void keyTyped(char c, int i) { super.keyTyped(c, i); textfield.textboxKeyTyped(c, i); } protected void mouseClicked(int i, int j, int k) { super.mouseClicked(i, j, k); textfield.mouseClicked(i, j, k); } public void drawScreen(int i, int j, float f) { // drawDefaultBackground(); int x = width / 2 - 125; int y = height / 2 - 100; FMLClientHandler.instance().getClient().renderEngine.func_110577_a(new ResourceLocation(Reference.MOD_ID, "/textures/gui/deftuasd.png")); drawTexturedModalRect(x, y, 0, 0, 256, 256); textfield.drawTextBox(); super.drawScreen(i, j, f); } }
  13. Where is that fade in effect rendered, cant find it anywhere
  14. Guff, go to this link. This guy helped me out w/ it and now mine works http://www.minecraftforum.net/topic/1945511-saving-data-w-items/
  15. hmhmhmhmhmhm
  16. o, its because tostore equals null.. But how can you get an instance of the full class but ensuring your variable is initialized? and the itemstack constructor is private
  17. toStore.writeToNBT(bagpack.getTagCompound()); This line probably cause it didnt have anything to write but I cant write cos I cant access it
  18. Caused an npe
  19. I already am if it dosent have a tagCompound though? if(! bagpack.hasTagCompound()) { bagpack.setTagCompound(writeToNBT(new NBTTagCompound())); System.out.println("call"); } else { System.out.println("call4"); writeToNBT(bagpack.getTagCompound()); }
  20. You gave me a ton of code but I dont know what you want me to put in closeChest out of that section
  21. Yes but which part specifically?
  22. do you understand what the code me n gotolink are talking about ? do you understand what it does ? if not which part are you still confused with ? how are your java skills? beginner intermediate advance ? because maybe its just a question of practice to know what to place where did you try anything ? println to see what placing the code at certain place does ? "do you understand what the code me n gotolink are talking about ? do you understand what it does ?" Not enough to be able to implement it correctly "how are your java skills? beginner intermediate advance ?" Im pretty familiar w/ all the common stuff, so sorta of intermediate/high beginner "if not which part are you still confused with ?" Just where to put it really aha
  23. i have no idea
  24. Stores 27 items. " the Container class has a onContainerClosed method, might be a good idea to save there, maybe you should be loading when the container opens ?" Thats what Im currently doing. I meant which bits should I replace w/ your code
  25. So where exactly would I put that and stuff, so Is my code no good or?
×
×
  • Create New...

Important Information

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