Jump to content

googoo1876

Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by googoo1876

  1. I was working on my mod, and it has a variable that should only be initiated on the server side. So before the constructor of my main mod I put a "public RadioHelper serverRadioHelper;" then in my preinit: if(side==Side.SERVER){ serverRadioHandler = new RadioHandler(); } and I access this variable in a tileenitity, and it throws a null pointer. I access it in updateEntity, here's the method: @Override public void updateEntity(){ if(hasStarted==false&&side==Side.SERVER){ hasStarted=true; //add to radio handler server side System.out.println("test"); CloudSound.instance.serverRadioHandler.addRadio(new RadioHelper(xCoord, yCoord, zCoord, worldObj.provider.dimensionId)); } } I'm clueless at the error right now. =/ Anyone have an idea?
  2. Eh, I'll stick with the container for now, but @Mazetar, that's pretty much what I've planned to do, have all radios put their coordinates in a list as there tile entities are initialized. =) Thanks for your help
  3. Huh, it works with a container, is there any reason why it must be a container? None of the tutorials mentioned it, and I has a Override annotation that didn't complain. =/
  4. Oh sorry, I didn't want to use his code, for looping though large amounts of blocks is being resource consuming, but with tile entities I had my own idea, but failed, anyways, I'll get code. Radio class with some unrelated code removed public class Radio extends Block { private Side side = FMLCommonHandler.instance().getEffectiveSide(); @SideOnly(Side.CLIENT) private Icon[] icons; private int id; public Radio (int id, Material material){ super(id, material); this.id=id; this.setCreativeTab(CreativeTabs.tabBlock); this.setHardness(5F); this.setUnlocalizedName("Radio"); @Override public boolean hasTileEntity(){ return true; } @Override public TileEntity createTileEntity(World world, int metadata){ System.out.println("test"); return new RadioTileEntity(); } } TileEntity class public class RadioTileEntity extends TileEntity{ @Override public void writeToNBT(NBTTagCompound par1){ super.writeToNBT(par1); } @Override public void readFromNBT(NBTTagCompound par1){ super.readFromNBT(par1); } @Override public void updateEntity(){ System.out.println("TEST?EDFRT"); } } Main mod file with some unrelated things removed package matthew.CloudSound; @Mod(modid="CloudSound", name="CloudSound", version="0.0.7") @NetworkMod(clientSideRequired=true, serverSideRequired=false, channels={"URLfrom", "URLto", "RadioBreak", "transmitter"}, packetHandler = PacketHandler.class) public class CloudSound { private Side side = FMLCommonHandler.instance().getEffectiveSide(); public Radio radio = new Radio(1000, Material.wood); public IronAntenna antenna= new IronAntenna(502, "Iron", Material.iron); public final static Transmitter transmitter= new Transmitter(500, Material.rock); public final WoodTransmitter woodTransmitter= new WoodTransmitter(501, Material.wood); //player is set in RAdioGUI public String player=null; ItemStack obsidian = new ItemStack(Block.obsidian); public TransmitterHandler transHandler = new TransmitterHandler(); ItemStack diamond = new ItemStack(Item.diamond, 64); // The instance of your mod that Forge uses. @Instance("CloudSound") public static CloudSound instance; // Says where the client and server 'proxy' code is loaded. @SidedProxy(clientSide="matthew.CloudSound.client.ClientProxy", serverSide="matthew.CloudSound.CommonProxy") public static CommonProxy proxy; @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { if(side==Side.CLIENT){ transHandler = new TransmitterHandler(); } Utils.makeStore(); // GameRegistry.registerPlayerTracker(new playerTracker()); NetworkRegistry.instance().registerConnectionHandler(new ConnectionHandler()); NetworkRegistry.instance().registerGuiHandler(this, new GuiHandler()); instance = this; } @Mod.EventHandler public void load(FMLInitializationEvent event) { proxy.registerRenderers(); GameRegistry.registerBlock(transmitter, "Transmitter"); GameRegistry.registerBlock(radio, "Radio"); GameRegistry.registerBlock(woodTransmitter, "Wood Transmitter"); GameRegistry.registerBlock(antenna, "IronAntenna"); GameRegistry.addRecipe(new ItemStack(transmitter), "xxx", "xyx", "xxx", 'x', obsidian, 'y', diamond); LanguageRegistry.addName(transmitter, "Transmitter"); LanguageRegistry.addName(woodTransmitter, "Wooden Transmitter"); LanguageRegistry.addName(antenna, "Iron Antenna"); LanguageRegistry.addName(radio, "Radio"); MinecraftForge.setBlockHarvestLevel(transmitter, "pickaxe", 3); MinecraftForge.setBlockHarvestLevel(woodTransmitter, "pickaxe", 1); GameRegistry.registerTileEntity(RadioTileEntity.class, "Radio"); }
  5. Huh, interesting code, but I think I found a way, but I need help. So originally I had two option for making a radio that would even work, make a tileentity with a small class to handle the radio, or just go all out in one huge handler class. I wanted to do the first, but I couldn't get tile entities working, so I went with the latter method. Now I want/need to use tile entities, because there is a updateEntity method which is called everytick. I thought perfect, but again I tried couldn't get tile entities to work >_<. I 1) Made a simple tile entity class extending tileentity with a updateEntity method that prints test 2) Put create tile entity in my block 3) Registered my tile entity with GameRegistry 4) Cried as all my attempts failed. >_<
  6. Issue with your idea is, that would cause lag with the max radius of 225.
  7. Okay, I'm making a radios mod, currently there are radios, and transmitters. The transmitters broadcast to a certain range, and send a packet with a URL and a few other details to all players that should hear sound, that being within the range of a radio block. So there are two ranges, a radio range, and a transmitter range, and if a player falls within a radio range that is within a transmitter range, the player should get a packet with a URL. How I originally wanted to do this was, I have an array of radios, and I just check if its in rage, issue is, this list only holds *active* radios(ones that are playing, or in the process of playing), and this array doesn't really need to be stored, so it isn't. My new idea is to require radios to be turned "on" with a redstone signal, and then to be added to the array. So a question, would onNeighborBlockChange run if there was a button press, or a redstone pulse? If not how would I go about doing that?
  8. OKay, so there's no (good)way to do this.. okay then I have to rethink my approach at this...
  9. Is there any way to get all blocks for a custom block type to do something? Say add their coordinates to a list?
  10. Thanks a ton! <3 I guess the last time I tried the code I was using to clean up was buggy, now it works flawlessly. Thank you Mew for your time too.
  11. @Mew Okay, here's a problem, you don't know your own name when you start a thread, the thread is started by a packet the server beams at you. The only place you could get a name is onblockactivate. @diesieben07 NOt sure what you are trying to get at, but the threads are client sided(for playing sound).
  12. @diesieben07 I did that before I used an IPlayerTracker, but it seems to face the same issue, I will double check, but I don't think it will help. @Mew I feel stupid now, that was an idea, and I thought if there was no thread made that wouldn't work. Now I realize if theres no thread made, there's no thread to clean up. xP I'll try Mews method, I'll report back whether it works or not.
  13. @BigDaveNz Yeah, I am/was using a IPlayerTracker, what I need to do is check if that EntityPlayer is you. Unfortunately, I know how to get that entity's name, and thats not particularly what I need. @Mew I'm really sorry, I'm trying my best to make this understandable, what I need to clear, I need to end a few threads running, that are specific to the world the player is playing in. Look at the code below me, I just need to find how to get thisPlayer. @Override public void onPlayerLogout(EntityPlayer player) { if(side==Side.CLIENT&&player.equals(thisPlayer)){ //cleanup } }
  14. This may or may not be your idea, but this is what I took from it, use the player.dat located in a single player world to get his/her name? That does seem reliable, for he may not have a single player world, multiple accounts on the same computer etc, but now I must sleep. Good night.
  15. Huh, I deleted my post because I felt as if I was making a fool of myself, now I really feel like a food, anyways. Well atleast I know how to use that function now, good luck to you.
  16. Yeah I'm definitely not making myself clear enough. I should start from the beginning, what I need to do is clean up for my mod when a person leaves the server. This clean up only should occur on the player who just left. How I originally thought to do this was to make a class implementing IPlayerTracker and add my code to onPlayerDisconnect. Now, in the beggining I didn't know this, but that method is called everywhere(all clients), whenever someone leaves. and you are given a instance of EntityPlayer. What I want to do is check if you are that player, and if you are clean up, elsewise, don't do anything. Does that make my goal anymore clear? Edit: Okay sorry Mew, you posted Minecraft.getMinecraft().thePlayer which works for SP, but this is a radio's mod, and its primary use is for servers... =/
  17. Hmm? Sorry, that not what I mean I mean the player username of the client thats running the mod. That sounds kinda confusing, a different way of phrasing it is to get the instance of player that is running the mod.
  18. Pardon all the simple questions, but I can't find how to get the username of the player that is client is being run on. Thanks.
  19. +1 to what Senitial said, the same thing happened to me, change your mod folder to lower case, and update the stuff in your mod code. I can't find it now, but I remember seeing someone else posting code from minecraft(not forge stuff), that pretty much translates your paths to lowercase, regardless if thats really the case.
  20. I started off trying to make an IPlayerTracker, that cleans up for my mod onPlayerLogout, but if you do it that way, all players on a server "clean up", when any player leaves, which would be an issue. I can't find any other way to do this though. Any ideas? Thanks.
  21. Is there anyway to get the dimension id of a player or word? I'm pretty stuck on this.
×
×
  • Create New...

Important Information

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