Jump to content

mrgreaper

Forge Modder
  • Posts

    105
  • Joined

  • Last visited

Everything posted by mrgreaper

  1. ah ok, that explains why i couldnt get it to work lol Love the stargate's
  2. having difficulty hooking the new 1.8.9 builds up with computer craft, the base of the stargate does not seem to be acting as a peripheral is there an extra step needed now? (did try the dhd, and chevlon and adding the iris lol ...been trying for over an hour to sus it out)
  3. i cant remember what went wrong, i believe it was fine in singleplayer but once in a multiplayer enviroment it failed or crashed. on my laptop i have my work around, basicly what i have done is made it play the sound if thier is one, and start a timer (all this is in the onUpdate) when the timer reaches x the sound is played again, this repeats until the sound given to it is nulled (its pretty much how pneumaticcraft does it), x in my case though is setup from my constants file which will have a list of all the sound files im likely to need to loop and thier length in ticks, so to get x i simply call the method in the constants with the sound name and it returns the length its not pretty its not efficent On a server with a bad tick rate it will have pauses in the loop but atleast i can understand it, at a much later point when my knowledge gets better i may be able to do it right but for now i have to settle for the work around, the end user should only notice a difference if the tps is low..it which point they have more important things to deal with then my sound file sounding wierd **edit** looking at some of the other threads and info on updating to 1.8 i kind of think i would be better scrapping what i have and starting again but at 1.8, granted some of the stuff in my mod wont work for months as they rely on other mods (or are addons to other mods) but better that then learn stuff that i will need to do differently in a few months anyway.
  4. it seems i had this problem before (http://www.minecraftforge.net/forum/index.php/topic,20966.msg106896.html#msg106896) sadly im cursed with a memory issue (short term and some long term is fine but other long term just...well gets deleted) read through it all and i feel i would of been better off not finding my old thread, more confused then ever Still i sort of understand packets now (i have even managed to successfully send one) and that may help. I confess i was hoping for a more newb friendly response then look at this class, trying to work it out from the class feels like reinventing the wheel given that other mods have done it successfully. **edit** nope, i just cant figure it out from the old thread and that class, i ny be missing something blindingly obvoiuse but then i wasnt taught java at school and i mod for fun, i have enough java knowledge to do something but this is clearly beyond me. for now i will play sound the only way i know how and have it play every x ticks where x is the length of ticks the file is.....if its on a server that has tick issues that could be bad but i see no way to do looped sounds and be server friendly. I dont get much free time between work and life hence my comment about not wanting to reinvent the wheel and have wasted what little i had tonight on trying this may try again at the end of the month when ill have more time.
  5. Ok first of all i have block in "" as im pretty sure its done in the blocks tileEntity and not the block itself...though im open to the posibility im wrong. A perfect example of what i want to achieve is the pulverisor or sawmill from ThermalExpansion, when the block is active it emits a noise, now i know how to register sounds (unless they are registered differently if we need them to loop ofcourse) so lets take a sound for an example laugh we have this line in our sounds.json (if additional stuff needs to be added let me know) "laugh": {"category": "master","sounds": [{"name": "laugh","stream": false}]}, how would we then trigger that sound to be heard from that "block " on a loop untill we tell it not to ? If its on a loop can we stop it and then start it with a different pitch? the goal im going for in my mod: my block detects its raining (done) if its raining it starts to charge up ...this will mean a sparking noise quiet and slow the duration being random, then a switch to the next sound file again random duration , a faster spark i now how to make a sound play once but not how to make it loop, im pretty sure thermal expansion arnt playing thier sound waiting for it to end then playing it again...but i could be wrong.
  6. ah i see, for some reason i thought it took only one value....hence my confusion. seems rather simple now lol thank you.
  7. ah! ok now its working! thank you i still dont get targetpoints though. Lets take an example of what i want to do, a tile entity will emit the speech synth and all with in a range of x will hear it.. now how i would do that on 1.6.4 is to use the code from the beacon to get all the players in a box and then play a sound at them (or in this case send a packet to them, 1 by 1 just going through the list of players in that range), the sendToAllAround seems like a god send, but i just dont know how to make it use the tile entitiy (or any entitiy/co-ords) as the main point...or how to tell it the range
  8. The reply is appreciated but i have read that a few times, thats how im as far as i am (it seemed the only uptodate one i could find and was referenced in a lot of other places) That doesnt help the issue though registering the packet....yep its registered implementing the packet class ...yep thats done implementing the packet handler...yep done (even did it inside the other class as shown, though i dont like having classes inside classes as thats new to me) sending packets.... done...but not working packet responses...not needed a response so havent done that, but it looks self explanatory
  9. Ok so im trying to get back into modding and to get something done i never managed before...packets i spent a fair while following some well made guides but nothing went right....turns out they were out of date lol so i searched more and i see "simple network wrapper" is the way to go, and i thought i had it sorted....untill i tried to use them in my main mod file i have public static SimpleNetworkWrapper network; ..snip.. @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { configHandler.init(event.getSuggestedConfigurationFile()); network = NetworkRegistry.INSTANCE.newSimpleChannel("messengerBunny"); //so we create the channel //here is where we add the pacets...registering one packet per class network.registerMessage(speechPacket.speechPacketHandler.class,speechPacket.class,0, Side.CLIENT);//so we are registering a packet called speechpacket to channel one of our network (the messenger bunny) hmmm ok can understand that permissions.init();//lets give the artists thier well deserved credit! creativeTabs.init();//set up the creative tabs blocks.init(); //lets load our blocks if (configHandler.RecordsEnabled){ records.init();} //load the records if (configHandler.BunnysEnabled){ bunnys.init();} // if bunnys are enabled we load them (this modular stuff is gonna kill me lol) FMLCommonHandler.instance().bus().register(new eventHandler());// load the event handlers MinecraftForge.EVENT_BUS.register(new eventHandler()); } ..snip.. then my packet is package com.mrgreaper.themrgmod.network; import com.mrgreaper.themrgmod.themrgmod; import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import net.minecraft.nbt.NBTTagCompound; /** * Created by david on 11/01/2015. */ public class speechPacket implements IMessage { private String message; private double voice; private float pitch; private float pitchRange; private float pitchShift; //private String voiceName; public speechPacket(){} //without this blank one the packet crashes ...why do we need it? arghhhhhhhhhh public speechPacket(String message,double voice,float pitch, float pitchRange, float pitchShift ){ this.message=message; this.voice=voice; this.pitchRange = pitchRange; this.pitch = pitch; this.pitchShift= pitchShift; } @Override public void fromBytes(ByteBuf buf) { // so we will need an nbt tag to store the info we want to send...here we read it NBTTagCompound tag = ByteBufUtils.readTag(buf); message = tag.getString("message"); voice = tag.getDouble("voice"); pitch = tag.getFloat("pitch"); pitchRange = tag.getFloat("pitchRange"); pitchShift = tag.getFloat("pitchShift"); } @Override public void toBytes(ByteBuf buf) { //and here we create it NBTTagCompound tag = new NBTTagCompound(); tag.setString("message",message); tag.setDouble("voice",voice); tag.setFloat("pitch",pitch); tag.setFloat("pitchRange",pitchRange); tag.setFloat("pitchShift",pitchShift); } public static class speechPacketHandler implements IMessageHandler <speechPacket,IMessage> { //so dont lile classes inside classes but everything i read suggests this is the way to go...still grrrrrr @Override public IMessage onMessage(speechPacket message, MessageContext ctx) { themrgmod.proxy.speechCreate(message.message,message.voice,message.pitch,message.pitchRange,message.pitchShift); return null; } } } that has the handler class inside it too now its called from my eventhandler (as a test) package com.mrgreaper.themrgmod.lib; import com.mrgreaper.themrgmod.network.speechPacket; import com.mrgreaper.themrgmod.themrgmod; import cpw.mods.fml.client.event.ConfigChangedEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; /** * Created by david on 11/01/2015. */ public class eventHandler { @SubscribeEvent public void onConfigurationChangeEvent(ConfigChangedEvent.OnConfigChangedEvent event) { if (event.modID.equalsIgnoreCase(constants.modid)) { configHandler.loadConfiguration(); } } @SubscribeEvent//test event public void TwistedPickupEvent(PlayerEvent.ItemPickupEvent event) { logHelper.info("if i can read this then the event handler is working" + event.pickedUp); themrgmod.network.sendToAll(new speechPacket("hello i think im working",12,23,12,3)); } } first a note on sendToAll.... i tried sentToAllAround as that seems perfect for the end goal....but it wanted a target point and nothing i tried to use as the target was valid including event.player.getPlayerCoordinates() which would be the specific co-ords to use but it wasnt having it event.player was also not valid for send to specific player. anyway the above results in this when you pickup an item I did have an unknown function error before i added the blank method call (as advised to someone with the same issue i had) also i realise i have a redundent step, the packet is sent to the client side so i dont really need to use the proxy (that makes sure the code is only run on the client side) but i cant see that hurting it (unless im wrong).
  10. old field is initialized here https://github.com/mrgreaper/TwistedMod2-reboot/blob/master/src/main/java/com/mrgreaper/twistedmod2/handlers/TwistedEventHandler.java#L30 well...created, it gets a value when the player holds an item. the idea being that it is supposed to stop the sound being played multiple times as on the second tick the code should say "oh thats what you were holding last tick ok" in idea and ssp this works fine (infact with out it i get the same issue in ssp as smp) no errors in the console, nothing of any use in the console at all as original post, all sounds that play on holding an item are glitching. my code is untidy agreed but then this is more a hobby, a play about for me rather then anything serous, though this issue is bugging me, as for redundent checks, when it comes to things that should only be on one side a redundent check wont hurt things. player name is being added to the item name to make it unique so in the instance running on johns client it will be johnitemname and wont conflict with the instance on freds computer otherwise when one player holds the item it would then not play for any other players as there is no way to tell the difference between john holding the item or fred (maybe i have this wrong, im self taught after all) the onEntityPlay is one of the methods i use, its what im used to and as i say works great in ssp and in idea, if using playSoundAtEntity() is the fix i will use that but if its exactly the same then why use that rather then what i know to work (atleast in ssp) the atWorldPlace was a test it plays a sound at a set of cordinates i pass through to it rather then the other one that targets the entity, again though its not relevent to the issue the full sound handler file package com.mrgreaper.twistedmod2.handlers; import com.mrgreaper.twistedmod2.reference.Reference; import net.minecraft.entity.Entity; import net.minecraft.world.World; /** * Created by david on 04/07/2014. */ public class SoundHandler { //for when we want complete control public static void onEntityPlay(String name, World world, Entity entityName, float volume, float pitch) { world.playSoundAtEntity(entityName, (Reference.MODID + ":" + name), (float) volume, (float) pitch); } //test sound handler public static void atWorldplace(World worldObj, double xCord, double yCord, double zCord, String SoundName, float volume, float pitch) { worldObj.playSoundEffect((double) xCord, (double) yCord, (double) zCord, (Reference.MODID + ":" + SoundName), (float) volume, (float) pitch); } //mini call to save typing public static void miniSoundPlay(String soundName, Entity entityName) { World world = entityName.worldObj; world.playSoundAtEntity(entityName, (Reference.MODID + ":" + soundName), 1, 1); } } given the lack of replys im guessing its a bug with forge thats causing the sound system to mess up in smp and not ssp so when i get home from work ill try a newer forge version
  11. so heres the issue, when a player holds certain items in my mod a sound is played just once at thier location. In ssp and in idea tests it works perfectly.....however when in multiplayer it trys to play the sound every tick! resulting in a barrage of noise. this is from my event handler class @SubscribeEvent public void TwistedTickEvent(TickEvent.PlayerTickEvent event) { //LogHelper.info("the event is working : TwistedTickEvent"); ItemStack itemstack = event.player.getCurrentEquippedItem(); if (itemstack != null) { current = (event.player.getDisplayName() + itemstack.getItem().getUnlocalizedName()).toString(); }//should clear up npe when we try to get the itemstack details from null or nothing ...oops else { current = (event.player.getDisplayName() + "item.nothing"); } //LogHelper.info("current = : " + current); //LogHelper.info("condition test 1 : " + current.equals(old)); if (!current.equals(old) && !event.player.worldObj.isRemote) { //LogHelper.info("should only be seen on one side"); old = current; if (itemstack != null) {//have to check its not null first or BLAM there goes the server when it trys to look up the item //i could do these as arrays in the sound.json....that would make adding and removing new sounds much easier....hmmm //TODO move these to arrays in sound.json ...possibly if (itemstack.getItem() == FluidInfo.orphanTearsBucket && !event.player.worldObj.isRemote){ //SoundHandler.onEntityPlay("orphanCry", event.player.worldObj, event.player,1,1); SoundHandler.atWorldplace(event.player.worldObj, event.player.posX, event.player.posY, event.player.posZ, "orphanCry", 1, 1);//test other sound methods } if (itemstack.getItem() == ItemInfo.itemDeathOrb && !event.player.worldObj.isRemote){ SoundHandler.onEntityPlay("deathOrbStartup", event.player.worldObj, event.player, 1, 1); } if (itemstack.getItem() == ItemInfo.itemDeadBunny && !event.player.worldObj.isRemote){ int ran =ThreadLocalRandom.current().nextInt(5)+1; switch(ran){ case 1: SoundHandler.miniSoundPlay("evilvoice-IsItDead",event.player); break; case 2: SoundHandler.miniSoundPlay("evilvoice-BringToLife",event.player); break; case 3: SoundHandler.miniSoundPlay("evilvoice-WeakBringLife",event.player); break; case 4: SoundHandler.miniSoundPlay("evilvoice-NoPower",event.player); break; case 5: SoundHandler.miniSoundPlay("evilvoice-WorldTremble",event.player); } } if (itemstack.getItem() == ItemInfo.itemLivingBunny && !event.player.worldObj.isRemote){ int ran =ThreadLocalRandom.current().nextInt(7)+1; switch(ran){ case 1: SoundHandler.miniSoundPlay("evilvoice-Beautiful",event.player); break; case 2: SoundHandler.miniSoundPlay("evilvoice-BeCareful",event.player); break; case 3: SoundHandler.miniSoundPlay("evilvoice-BurnIt",event.player); break; case 4: SoundHandler.miniSoundPlay("evilvoice-LookCreated",event.player); break; case 5: SoundHandler.miniSoundPlay("evilvoice-NoseTwitch",event.player); break; case 6: SoundHandler.miniSoundPlay("evilvoice-ReleaseEvilCreature",event.player); break; case 7: SoundHandler.miniSoundPlay("evilvoice-ThePowerCalls",event.player); break; } } if (itemstack.getItem() == ItemInfo.itemOrphanLeg && !event.player.worldObj.isRemote){ int ran =ThreadLocalRandom.current().nextInt(3)+1; switch(ran){ case 1: SoundHandler.miniSoundPlay("evilvoice-Delicous",event.player); break; case 2: SoundHandler.miniSoundPlay("evilvoice-DoNotPityOrphan",event.player); break; case 3: SoundHandler.miniSoundPlay("evilvoice-Replant",event.player); break; case 4: //SoundHandler.miniSoundPlay("evilvoice-NoPower",event.player); break; case 5: //SoundHandler.miniSoundPlay("evilvoice-WorldTremble",event.player); } } if (itemstack.getItem() == ItemInfo.itemEnergizedBunny && !event.player.worldObj.isRemote) { int ran = ThreadLocalRandom.current().nextInt(5) + 1; switch (ran) { //use that number case 1: SoundHandler.onEntityPlay("bunnyBegA", event.player.worldObj, event.player, 1, 1); break; case 2: SoundHandler.onEntityPlay("bunnyBegB", event.player.worldObj, event.player, 1, 1); break; case 3: SoundHandler.onEntityPlay("bunnyBegC", event.player.worldObj, event.player, 1, 1); break; case 4: SoundHandler.onEntityPlay("bunnyBegD", event.player.worldObj, event.player, 1, 1); break; case 5: SoundHandler.onEntityPlay("bunnyBegE", event.player.worldObj, event.player, 1, 1); break; } } } } } and this is my sound handler public static void onEntityPlay(String name, World world, Entity entityName, float volume, float pitch) { world.playSoundAtEntity(entityName, (Reference.MODID + ":" + name), (float) volume, (float) pitch); } this is forge 1188 mc 1.7.10 any ideas why my mod is not working right in smp?
  12. indeed this^ i decided to take the cowards route and just make them seperate mods that include the same classes, given the package names will be different it shouldnt be too much of an issue, it would be better to have a core mod that my other mods use but my knowedge of java is just not there yet.
  13. Ok so heres the situation, my mod has parts of it people want to use seperate...and indeed i understand that as the main part of it is strange and dark humour. Looking at my code i can see that i essentialy have 3 distinct mods in one. So the easy solution? well split it up into 3 different mods... BUT i have handlers that are used by all of them, so i got to thinking how the professional modders do it, they have a core-mod (ok yeah thats a misleading name for it, but i cant think what to call it lol) I examined the libairies i use, and came on to this idea, i just want to know if im going the right way: im taking all the handlers from my mod, all the librairies it uses, all the sound files it uses(not sure if i should part the sound files or not yet). Im making that its own mod, once compiled i will put that in the libs folder of each of the mods i split from it my theory is that when im in the ide i will be able to reference the handlers just like i can when its all part of the mod, when i compile the mod the lib wont be included (i know how to include it ofcourse, but im thinking i shouldnt for the reasons below) so a player would need the compiled mod lib in thier mods folder and what ever of my mods they want so for example if a player wants my twisted mod and my security mod they would need core.jar twisted.jar security.jar ... but should they want just the twisted one they would simply not get the security.jar have i grasped that correctly? is thier a special way of doing this?
  14. ok after a lot of searching i found a method that takes an image and draws it at the co-ordinates you specify at the size you request //ok lets see x and y are the location of where the image will be placed, width and height are the size you want it ...zlevel? public static void drawTexturedQuadFit(double x, double y, double width, double height, double zLevel){ Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.addVertexWithUV(x + 0, y + height, zLevel, 0,1); tessellator.addVertexWithUV(x + width, y + height, zLevel, 1, 1); tessellator.addVertexWithUV(x + width, y + 0, zLevel, 1,0); tessellator.addVertexWithUV(x + 0, y + 0, zLevel, 0, 0); tessellator.draw(); } but it draws the WHOLE texture so heres my dilema i can have a tiny small part of the texture (not even the right part) OR have it the right size but all of the texture instead i could cut a whole in the texture for the gui and have the skin render under it positioned right, but that just seems ...wrong is there a way to tell this method to just use part of the texture? i looked at the tessellator.class but cant see anything that would help
  15. well this is the code i now have package com.mrgreaper.twistedmod2.gui; import com.mrgreaper.twistedmod2.handlers.ReaperHelper; import com.mrgreaper.twistedmod2.reference.Reference; import com.mrgreaper.twistedmod2.utility.LogHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; /** * Created by david on 10/07/2014. */ public class guiSecurityIdCard extends GuiScreen { private final EntityPlayer viewer; private final String accesscode; private String username; ResourceLocation bground = new ResourceLocation(Reference.MODID + ":" + "textures/gui/SecurityId.png"); private ResourceLocation ownerface; public final int xSize = 220; //the width of your texture public final int ySize = 152; //the height of our texture public final int faceXSize = 64; // the image we get for the face should always be the same size! public final int faceYsize=32; public final int faceStartX = 8; //where the face starts public final int faceStartY = 8; public final int faceOverlayStartX=40; //face is made of two parts public final int faceOverlayStartY=8;//not really needed as its ths same height as face start y but meh it keeps it neat private int guiLeft; private int guiTop; public guiSecurityIdCard(EntityPlayer player, String code, String user) { //hmmm really needed that to be the itemstack...gonna have to do some wierd stuff here this.viewer = player; this.accesscode = user;//yeah i got them the long way around and im being lazy this.username = code; this.ownerface = new ResourceLocation(ReaperHelper.getSkin(username)+""); } @Override public void drawScreen(int x, int y, float f) { drawDefaultBackground(); //draws default background (an overlay in the background) GL11.glColor4f(1f, 1f, 1f, 1f); //set the colour to black (yeah the method is missing a u but that seems common in minecraft this.guiLeft = (this.width - this.xSize) / 2; //so we can center the gui on the screen this.guiTop = (this.height - this.ySize) / 2; Minecraft.getMinecraft().getTextureManager().bindTexture(bground); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); Minecraft.getMinecraft().getTextureManager().bindTexture(ownerface); drawTexturedModalRect(guiLeft+30,guiTop+25,faceStartX,faceStartY,8,; drawTexturedModalRect(guiLeft+30,guiTop+25,faceOverlayStartX,faceOverlayStartY,8,; drawCenteredString(fontRendererObj, username, guiLeft + 145 - username.length(), guiTop + 30, 0x0055cc); LogHelper.info(ReaperHelper.getSkin(username)); if (viewer.getDisplayName().equals(username)) { drawCenteredString(fontRendererObj, accesscode, guiLeft + 155 - accesscode.length(), guiTop + 80, 0x66ff66); } else { drawCenteredString(fontRendererObj, EnumChatFormatting.OBFUSCATED + accesscode, guiLeft + 155 - accesscode.length(), guiTop + 80, 0xee0000); } //above sets the background texture super.drawScreen(x, y, f); } @Override public boolean doesGuiPauseGame() { return false; //dont pause the game } } the method you gave me i put into a handler class as it may be useful for other stuff too it gets the texture fine, in one test i made the whole gui background the skin so i could check it and it was there now if im right the texture it gets is the same as this one http://s3.amazonaws.com/MinecraftSkins/mrgreaper.png (as the username im passing on to it is mrgreaper) so that puts it at 64x32 with the face starting at 8,8 and being 8 across and 8 height the overlay for the face (as it is actually two parts of the texture) starts at 40,8 and is also 8 across by 8 high. so i bound those to variables (final as they should be the same for any skin download) and Minecraft.getMinecraft().getTextureManager().bindTexture(ownerface); drawTexturedModalRect(guiLeft+30,guiTop+25,faceStartX,faceStartY,8,; drawTexturedModalRect(guiLeft+30,guiTop+25,faceOverlayStartX,faceOverlayStartY,8,; should of placed first the face and then the overlay but the result is this that little tiny square....ok so the size makes sense, need some way to make it bigger(is that possible) but what doesnt make sense is its not the right part of the skin, i checked using paint.net and it all seems to tally up, however earlier when i tried using a higher res image for the background it too went wrong (i ofcourse adjusted my xSize and ySize) and indeed the only way to get the gui image to work right on this back ground was to adjust the xSize and zSize to a size beyond what it is (something wrong somewhere but) any ideas?
  16. i have been playing around with adding and reading nbt tags from item stacks today (have a look at the video and item code i posted here http://www.minecraftforge.net/forum/index.php/topic,21125.0.html) at one point the accessCode String i added to my nbt was so long it took up the whole screen but given you would only need to store the textures name (you can use the modid to get the first part of a textures location) i dont see why it wouldnt work wonder if you can dynamicly change the unlocalised name? that would allow you to change the skin and using the lang file, the name of the sword (if you set up the skins to load based on the unlocalised name hope that helps
  17. Ok with my problem block for the moment behind me, i started working on more fun stuff to be able to learn a bit more on GUI and NBT etc What i would like to do is be able to download the Face texture of a player from a displayname (or any descriptor i need that i can save to an nbt) and display it on a gui (resized if needed) The why... too long winded to put into text so i did a video (its just easier for me, and im sure many wont be fussed about the why...though im chuffed with what i achieved so far) https://www.youtube.com/watch?v=Jk2C0GaadWQ if you watched the video and want to know the code behind it the item is public class itemSecurityId extends twistedItems { //while learning nbt tags i came across a guide for keys, it gave me an idea for security ids, these will be used in two ways //1 on a secure alarmblock that will only shut off when right clicked with an authorized id card //2 a secure block that will stop emiting redstone only when right clicked with a authorized id card @Override //ok so when the item is created we make a nbt tag but not as i know it public void onCreated(ItemStack itemStack, World world, EntityPlayer player) { LogHelper.info("item created"); makeNBT(itemStack, player); //lets make it a function so we can call it if theres not a tag:) } @Override public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) { if (itemStack.stackTagCompound != null) { String owner = itemStack.stackTagCompound.getString("user"); String code = itemStack.stackTagCompound.getString("accessCode"); list.add("Id Belongs to : " + owner); if (owner.equals(player.getDisplayName())) { list.add(EnumChatFormatting.GREEN + "Pass Code : " + code); } else { list.add(EnumChatFormatting.RED + "Pass Code : " + EnumChatFormatting.OBFUSCATED + code); } } } @Override public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { LogHelper.info("security id right clicked"); if (!player.isSneaking()) { if (itemStack.stackTagCompound != null) { } else { LogHelper.info("no tag compound lets make one"); makeNBT(itemStack, player); } } else { if (itemStack.stackTagCompound != null) { FMLNetworkHandler.openGui(player, TwistedMod2.instance, BlockInfo.guiIDSecurityId, world, (int) player.posX, (int) player.posY, (int) player.posZ); } else { LogHelper.info("no tag compound lets make one"); makeNBT(itemStack, player); } } return itemStack; } public void makeNBT(ItemStack itemStack, EntityPlayer player) { itemStack.stackTagCompound = new NBTTagCompound(); itemStack.stackTagCompound.setString("user", player.getDisplayName()); //we get the username and set it as the string tag "user" itemStack.stackTagCompound.setString("accessCode", ReaperHelper.securityCode());//ok lets get a REALLY big number lol } } the Gui is public class guiSecurityIdCard extends GuiScreen { private final EntityPlayer viewer; private final String accesscode; private final String username; ResourceLocation bground = new ResourceLocation(Reference.MODID + ":" + "textures/gui/SecurityId.png"); public final int xSizeOfTexture = 220; //the width of your texture public final int ySizeOfTexture = 152; //the height of our texture public guiSecurityIdCard(EntityPlayer player, String code, String user) { //hmmm really needed that to be the itemstack...gonna have to do some wierd stuff here this.viewer = player; this.accesscode = user;//yeah i got them the long way around and im being lazy this.username = code; } @Override public void drawScreen(int x, int y, float f) { drawDefaultBackground(); //draws default background (an overlay in the background) GL11.glColor4f(1f, 1f, 1f, 1f); //set the colour to black (yeah the method is missing a u but that seems common in minecraft int posX = (this.width - xSizeOfTexture) / 2; //so we can center the gui on the screen int posY = (this.height - ySizeOfTexture) / 2; Minecraft.getMinecraft().getTextureManager().bindTexture(bground); drawTexturedModalRect(posX, posY, 0, 0, xSizeOfTexture, ySizeOfTexture); drawCenteredString(fontRendererObj, username, posX + 145 - username.length(), posY + 30, 0x0055cc); if (viewer.getDisplayName().equals(username)) { drawCenteredString(fontRendererObj, accesscode, posX + 155 - accesscode.length(), posY + 60, 0x66ff66); } else { drawCenteredString(fontRendererObj, EnumChatFormatting.OBFUSCATED + accesscode, posX + 155 - accesscode.length(), posY + 60, 0xee0000); } //above sets the background texture super.drawScreen(x, y, f); } @Override public boolean doesGuiPauseGame() { return false; //dont pause the game } } my gui handler is (TBH i should pass on the itemstack and do the nbt checking inside the gui to allow better access to it) public class GuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {//ok so if we are going to have gui on some items i need to not check to see if the tile entity is legit...after all it wont be in existence TileEntity entity = world.getTileEntity(x, y, z); switch (ID) { case BlockInfo.guiIDBunnyFurnace: LogHelper.info("gui choice....bunny furnace"); if (entity instanceof TileEntityBunnyFurnace) { return new ContainerBunnyFurnace(player.inventory, (TileEntityBunnyFurnace) entity); } return null; case BlockInfo.guiIDLivingBunny: LogHelper.info("gui choice....living bunny"); return new ContainerLivingBunny(player); case BlockInfo.guiIDSecurityId: return new ContainerLivingBunny(player); } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { //ok so if we are going to have gui on some items i need to not check to see if the tile entity is legit...after all it wont be in existence TileEntity entity = world.getTileEntity(x, y, z); switch (ID) { case BlockInfo.guiIDBunnyFurnace: if (entity instanceof TileEntityBunnyFurnace) { return new GuiBunnyFurnace(player.inventory, (TileEntityBunnyFurnace) entity); } return null; case BlockInfo.guiIDLivingBunny: return new GuiLivingBunny(player); case BlockInfo.guiIDSecurityId: return new guiSecurityIdCard(player, player.getCurrentEquippedItem().stackTagCompound.getString("user"), player.getCurrentEquippedItem().stackTagCompound.getString("accessCode")); } return null; } } it also has a standard container but no need to show that as its generic if you look at the youtube video and want to use the code for your own open source mod, go for it, just if you fix any errors i have made let me know! and give me a nod in the credits the github is at https://github.com/mrgreaper/TwistedMod2-reboot/
  18. No. You need to understand how Server & Client work. indeed i do, no argument from me on that, i had untill today assumed that since 1.3.x the client was a locally run in the background server that it auto connects to, i am not sure where i got that idea from now but it was a firm belief that it was not different to a dedicated server / client connection the minute i changed false to true the sound played (thank you!) ...havent compiled it for test on a server yet as i still need to change the ability to stop it as well im guessing im using them right and not bodge jobbing it lol glad i dont need manual packets, it does appear they have been changed and not documented yet, still im using forge for 1.7.10 and its not had a recommanded build yet so i cant moan when something is not as the wiki says it to be lol **edit** its now working on the server too THANK YOU! i need to find a way to make it restart the sound if the server/chunk is deloaded but that can wait(not talking about saving states as i know that and have nbt tags for it but more some way to poll the sound to see if its avtive and if not set the should start to true again... NO NO NO NO this block is done for now! i refuse to give it anymore of my soul!)
  19. ok so my block class looks like this now public class blockAlarmSpeaker extends BlockContainer { private TileEntitySpeaker tile; //we will need this for checking booleans and methods that are unique to TileEntitySpeaker public blockAlarmSpeaker(Material material) { super(material); this.setHardness(3.0f); this.setResistance(5.0f); this.setStepSound(soundTypeMetal); this.setCreativeTab(TwistedMod2.TwistedModTab); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon(Reference.MODID + ":" + this.getUnlocalizedName().substring(5)); } @Override public TileEntity createNewTileEntity(World world, int i) { return new TileEntitySpeaker(); //creating the tile entity } @Override public void onNeighborBlockChange(World world, int xCord, int yCord, int zCord, Block blockID) { if (!world.isRemote && !world.isBlockIndirectlyGettingPowered(xCord, yCord, zCord)) { //ok so if we are server side and we are NOT getting power but there has been a block update tile = (TileEntitySpeaker) world.getTileEntity(xCord, yCord, zCord); //we make sure tile is the TileEntity that is located at our blocks location tile.setShouldStop(true); //we tell the tileEntitySpeaker that we want shouldStop to be true } if (world.isBlockIndirectlyGettingPowered(xCord, yCord, zCord)) { //we check to see if we are server side and if the block is getting powered and if theres been a block update around us tile = (TileEntitySpeaker) world.getTileEntity(xCord, yCord, zCord); //we make sure that tile is the TileEntitySpeaker thats at our blocks location (ok were not checking it is a TileEntitySpeaker, more casting it as...should be though unless something went wrong) //tile.setShouldStart(true); //we tell the tileEntitySpeaker that we want shouldStart to be true world.addBlockEvent(xCord,yCord,zCord,this,0,0); //hmm so (x,y,z, block? if thats this block then this, event id, event paramater?) LogHelper.info("Block event sent: block was "+this+" x:"+xCord+" y:"+yCord+" z:"+zCord); } } @Override public boolean onBlockEventReceived(World world, int x, int y, int z, int eventId, int eventPramater) { LogHelper.info("i recieved a block event with world:"+world+" x:"+x+" y:"+y+" z:"+z+" event id :"+eventId+"event paramater :"+eventPramater); if (world.isRemote && eventId==0){ LogHelper.info("i realised that im on the client side and that the id is 0 so i will now tell the tile to start"); tile = (TileEntitySpeaker) world.getTileEntity(x, y, z); tile.setShouldStart(true); } if (!world.isRemote && eventId==0) { LogHelper.info("and im on the server side but i noticed that the block was updated and that the id was 0 ...i wont tell the sound to start though"); } return false; } } and i changed my tile entity to be public class TileEntitySpeaker extends TileEntity { private boolean isPlaying = false; //when the tile entity is created we want to have it not playing private boolean shouldStart = false; //the triger we will use to start the sound private boolean shouldStop = false; private String soundName = "alarm-airraidA"; //setting the default sound name, later a gui will allow me to change it private float volume = 2f; //default volume set to 2 that should be 32 block radius, later a gui will help me to change it @Override public void updateEntity() { if (!isPlaying && shouldStart) {//check to see if we are not already playing (to stop infinite amounts playing) and if we should start shouldStart = false; //set should start to false to stop us trying to play more shouldStop = false; //this is so when we have played and then stopped we can play again...yeah that was a bugger to solve! isPlaying = true; //we tell it we are now playing //TODO need to use a proxy for this....ahhhh crap // AlarmHandler alarm = new AlarmHandler(TileEntitySpeaker.this, soundName,volume,this); // AlarmHandler2 alarm2 = new AlarmHandler2(worldObj.getTileEntity(xCoord, yCoord, zCoord), "alarm-airraidA"); //create a new instance of the alarmhandler2 //Minecraft.getMinecraft().getSoundHandler().playSound(alarm2); //make some noise if (this.worldObj.isRemote) { TwistedMod2.proxy.alarmSound(worldObj.getTileEntity(xCoord, yCoord, zCoord), soundName);} } } public boolean isShouldStop() { //so we can see if we should stop this method allows checking for it return shouldStop; } public void setShouldStart(boolean shouldStart) { //this is what we call from our block and set to true to play sound this.shouldStart = shouldStart; } public void setShouldStop(boolean shouldStop) { //we call this to stop the sound..well to set it up to stop if (isPlaying) { //we make sure sound is playing, otherwise a bug in the way minecraft deals with block updates causes it to start and stop immediatly isPlaying = false; //since were stoping it we set this to false to say the sound is no longer playing this.shouldStop = shouldStop; } } public boolean isPlaying() { //we use this to allow other classes to see if were playing or not return isPlaying; } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); soundName = nbt.getString("sndName"); shouldStop = nbt.getBoolean("shouldStop"); shouldStart = nbt.getBoolean("shouldStart"); volume = nbt.getFloat("vol"); } @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setString("sndName", soundName); nbt.setBoolean("shouldStop", shouldStop); nbt.setBoolean("shouldStart", shouldStart); nbt.setFloat("vol", volume); //we allow isPlaying to reset itself to false...i possibly dont need to save some of the others lol } } now when i pull the lever i get no sound and the following gets put into the log [23:57:36] [server thread/INFO] [Mr G's Twisted Mod]: Block event sent: block was com.mrgreaper.twistedmod2.blocks.blockAlarmSpeaker@951e077 x:-7 y:64 z:355 [23:57:36] [server thread/INFO] [Mr G's Twisted Mod]: Block event sent: block was com.mrgreaper.twistedmod2.blocks.blockAlarmSpeaker@951e077 x:-7 y:64 z:355 [23:57:36] [server thread/INFO] [Mr G's Twisted Mod]: i recieved a block event with world:net.minecraft.world.WorldServer@46da830c x:-7 y:64 z:355 event id :0event paramater :0 [23:57:36] [server thread/INFO] [Mr G's Twisted Mod]: and im on the server side but i noticed that the block was updated and that the id was 0 ...i wont tell the sound to start though so its firing that block event twice in quick succesion (probably due to the way the block updates work) but thats not an issue it detects the block event, yay BUT it only recieves it on the server side i already removed the sided check from the onNeighborBlockChange for when it detects redstone so that *shouldnt* be an issue have i missed something? im gonna grab a coffee and read through packet handling on the wiki(http://www.minecraftforge.net/wiki/Advanced_Packet_Handling **), maybe i need to do that instead. I dont see why the blockevent detection is only happening server side **edit** read it and the prerequisite page a few times, sort of understand it, the rest im sure ill get when i try it.... so i just went to try it ...IPacketHandler does not exist BLEEEEEEEEEEEP the page is dated may, not marked out of date, thats only 2 months ago and the method has changed ok need more coffee
  20. Thought the proxy ment that now the sound is only triggered on the client side? i hate this block i did try removing the sided check from the on neigbour check believeing that to be the issue but nothing changed. after looking through it and trying different things for a couple of hours i came to the conclusion that it must be a forge or minecraft bug, everything looks right and it plays ok in single player and the ide etc it hadnt occured to me that it may be a bug that it actually plays in single player and shouldnt actually be working there! ok ill look into block events (i know nothing of them as yet, but if they act just like forge events it should be easy enough to learn them) guess i dont need that proxy after all lol! or actually...do i ? hmmm cant hurt to keep it in my holiday ends in an hour (still have a rest day left after that) i had hoped to do so much on my mod but got stuck on this damn block so wish forge had a good way of making sounds loop with out having to use the stuff ment for minecarts lol)
  21. ok so in my IProxy i have public interface IProxy { public abstract void alarmSound(TileEntity tileEntity, String soundName); }[code] in my server proxy i have [code]public class ServerProxy extends CommonProxy { @Override public void alarmSound(TileEntity tileEntity, String soundName) { //dont do it! sounds are client side...bad mod ...dont make me get the newspaper! } } in my client proxy i have public class ClientProxy extends CommonProxy { @Override public void alarmSound(TileEntity tileEntity, String soundName) { AlarmHandler2 alarm2 = new AlarmHandler2(tileEntity, "alarm-airraidA"); //create a new instance of the alarmhandler2 Minecraft.getMinecraft().getSoundHandler().playSound(alarm2); //make some noise } } my amended tileentity is public class TileEntitySpeaker extends TileEntity { private boolean isPlaying = false; //when the tile entity is created we want to have it not playing private boolean shouldStart = false; //the triger we will use to start the sound private boolean shouldStop = false; private String soundName = "alarm-airraidA"; //setting the default sound name, later a gui will allow me to change it private float volume = 2f; //default volume set to 2 that should be 32 block radius, later a gui will help me to change it @Override public void updateEntity() { if (!isPlaying && shouldStart) {//check to see if we are not already playing (to stop infinite amounts playing) and if we should start shouldStart = false; //set should start to false to stop us trying to play more shouldStop = false; //this is so when we have played and then stopped we can play again...yeah that was a bugger to solve! isPlaying = true; //we tell it we are now playing // AlarmHandler alarm = new AlarmHandler(TileEntitySpeaker.this, soundName,volume,this); // AlarmHandler2 alarm2 = new AlarmHandler2(worldObj.getTileEntity(xCoord, yCoord, zCoord), "alarm-airraidA"); //create a new instance of the alarmhandler2 //Minecraft.getMinecraft().getSoundHandler().playSound(alarm2); //make some noise TwistedMod2.proxy.alarmSound(worldObj.getTileEntity(xCoord,yCoord,zCoord),soundName); } } public boolean isShouldStop() { //so we can see if we should stop this method allows checking for it return shouldStop; } public void setShouldStart(boolean shouldStart) { //this is what we call from our block and set to true to play sound this.shouldStart = shouldStart; } public void setShouldStop(boolean shouldStop) { //we call this to stop the sound..well to set it up to stop if (isPlaying) { //we make sure sound is playing, otherwise a bug in the way minecraft deals with block updates causes it to start and stop immediatly isPlaying = false; //since were stoping it we set this to false to say the sound is no longer playing this.shouldStop = shouldStop; } } public boolean isPlaying() { //we use this to allow other classes to see if were playing or not return isPlaying; } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); soundName = nbt.getString("sndName"); shouldStop = nbt.getBoolean("shouldStop"); shouldStart = nbt.getBoolean("shouldStart"); volume = nbt.getFloat("vol"); } @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setString("sndName", soundName); nbt.setBoolean("shouldStop", shouldStop); nbt.setBoolean("shouldStart", shouldStart); nbt.setFloat("vol", volume); //we allow isPlaying to reset itself to false...i possibly dont need to save some of the others lol } } tested the mod in Idea and the speakers work perfectly still ! wooo the proxy works compiled the mod and added it to the server and my client loaded up the client, tested the block...still works perfectly loaded up the server (wiping the world first to remove risk of bad tile entities) placed the block and no server crash yes pulled the lever....no sound....wtf where did i go wrong? why is it working in single player (which is a server-client enviroment as far as im aware) but not on a dedicated server? theres no errors , just no sound i have pushed the changes to my github but i cant see any coding errors **edit** tested the sounds i have when you hold certain items and they work fine its just this damn alarm one **edit 2** for the last 2 hours i have gone through it again and again nothing seems wrong and yet no sound i recorded a video to show it (yeah wrong mic got used) https://www.youtube.com/watch?v=bAEdNbeamd8 im thinking its a bug with minecraft or forge?
  22. yep just built a version with AlarmHandler2 alarm2 = new AlarmHandler2(worldObj.getTileEntity(xCoord, yCoord, zCoord), "alarm-airraidA"); //create a new instance of the alarmhandler2 Minecraft.getMinecraft().getSoundHandler().playSound(alarm2); //make some noise commented out and no crash, wierd that it crashes with them in as that part of the code is not run untill the conditions are met i thought with @SideOnly and isRemote i would never need a proxy, i have one setup just never used it, im off to find how to, if you know a good guide that describes its use then that would be helpful (google is bringing a lot of unwanted/unrelated hits) if memory serves i call a function in the proxy which splits in two and if its on the client side it does one thing if its on the server side another (the thing it does can be nothing) ...but i may be wrong on that, plus if the instance of alarm is created in the proxy wouldnt that mean i would no longer have 1 per tile entity? hmmmmm i need a coffee and to do some serous researching ....blockAlarmSpeaker ..you have become the bane of my existance **edit** hmmm i think i have figured it out....but it seems too easy to be right
  23. Your right, i created a server compiled my mod and tested it sure enough on placing the block BANG server dies arghhhhhhhhhhhhhhhhhhhhh i thought the issues with this block were behind me! and why THAT error, when placing it sound is being played i dont create an instance of the alarm handler class untill i tell it to make a noise (thats not on block creation) had it of been when it recieved a signall i could see how to fix it ah man i hate this block with a passion. edit indeed it is when we create the tileentity Time: 09/07/14 18:12 Description: Exception in server tick loop java.lang.NoClassDefFoundError: net/minecraft/client/audio/ISound at com.mrgreaper.twistedmod2.blocks.blockAlarmSpeaker.func_149915_a(blockAlarmSpeaker.java:40) at net.minecraft.block.Block.createTileEntity(Block.java:1444) thinking about it...we import the alarm on create so yeah ...but how the hell to fix that, cant have the tile entity client side only, cant only import stuff client side arghhhhhhhhhh
  24. i dont understand, why would it go wrong? the tile entity is only given the signal to start if we are on the server side form my block : @Override public void onNeighborBlockChange(World world, int xCord, int yCord, int zCord, Block blockID) { if (!world.isRemote && !world.isBlockIndirectlyGettingPowered(xCord, yCord, zCord)) { //ok so if we are server side and we are NOT getting power but there has been a block update tile = (TileEntitySpeaker) world.getTileEntity(xCord, yCord, zCord); //we make sure tile is the TileEntity that is located at our blocks location tile.setShouldStop(true); //we tell the tileEntitySpeaker that we want shouldStop to be true } if (!world.isRemote && world.isBlockIndirectlyGettingPowered(xCord, yCord, zCord)) { //we check to see if we are server side and if the block is getting powered and if theres been a block update around us tile = (TileEntitySpeaker) world.getTileEntity(xCord, yCord, zCord); //we make sure that tile is the TileEntitySpeaker thats at our blocks location (ok were not checking it is a TileEntitySpeaker, more casting it as...should be though unless something went wrong) tile.setShouldStart(true); //we tell the tileEntitySpeaker that we want shouldStart to be true } } }
  25. Ok so i managed to get it done with 1 tile entity (both on and off functionality, as well as the ability to work more then once...hay that may not sound impressive but well...it is ok!) Incase others stumble on this thread with the same issue here is a rather over commented version of the related files (note though this may not be the best or the right way to do it lol) The block file public class blockAlarmSpeaker extends BlockContainer { private TileEntitySpeaker tile; //we will need this for checking booleans and methods that are unique to TileEntitySpeaker public blockAlarmSpeaker(Material material) { super(material); this.setHardness(3.0f); this.setResistance(5.0f); this.setStepSound(soundTypeMetal); this.setCreativeTab(TwistedMod2.TwistedModTab); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon(Reference.MODID + ":" + this.getUnlocalizedName().substring(5)); } @Override public TileEntity createNewTileEntity(World world, int i) { return new TileEntitySpeaker(); //creating the tile entity } @Override public void onNeighborBlockChange(World world, int xCord, int yCord, int zCord, Block blockID) { if (!world.isRemote && !world.isBlockIndirectlyGettingPowered(xCord, yCord, zCord)) { //ok so if we are server side and we are NOT getting power but there has been a block update tile = (TileEntitySpeaker) world.getTileEntity(xCord, yCord, zCord); //we make sure tile is the TileEntity that is located at our blocks location tile.setShouldStop(true); //we tell the tileEntitySpeaker that we want shouldStop to be true } if (!world.isRemote && world.isBlockIndirectlyGettingPowered(xCord, yCord, zCord)) { //we check to see if we are server side and if the block is getting powered and if theres been a block update around us tile = (TileEntitySpeaker) world.getTileEntity(xCord, yCord, zCord); //we make sure that tile is the TileEntitySpeaker thats at our blocks location (ok were not checking it is a TileEntitySpeaker, more casting it as...should be though unless something went wrong) tile.setShouldStart(true); //we tell the tileEntitySpeaker that we want shouldStart to be true } } } the tile entity public class TileEntitySpeaker extends TileEntity { private boolean isPlaying = false; //when the tile entity is created we want to have it not playing private boolean shouldStart = false; //the triger we will use to start the sound private boolean shouldStop = false; private String soundName = "alarm-airraidA"; //setting the default sound name, later a gui will allow me to change it private float volume = 2f; //default volume set to 2 that should be 32 block radius, later a gui will help me to change it @Override public void updateEntity() { if (!isPlaying && shouldStart) {//check to see if we are not already playing (to stop infinite amounts playing) and if we should start shouldStart = false; //set should start to false to stop us trying to play more shouldStop = false; //this is so when we have played and then stopped we can play again...yeah that was a bugger to solve! isPlaying = true; //we tell it we are now playing // AlarmHandler alarm = new AlarmHandler(TileEntitySpeaker.this, soundName,volume,this); AlarmHandler2 alarm2 = new AlarmHandler2(worldObj.getTileEntity(xCoord, yCoord, zCoord), "alarm-airraidA"); //create a new instance of the alarmhandler2 Minecraft.getMinecraft().getSoundHandler().playSound(alarm2); //make some noise } } public boolean isShouldStop() { //so we can see if we should stop this method allows checking for it return shouldStop; } public void setShouldStart(boolean shouldStart) { //this is what we call from our block and set to true to play sound this.shouldStart = shouldStart; } public void setShouldStop(boolean shouldStop) { //we call this to stop the sound..well to set it up to stop if (isPlaying) { //we make sure sound is playing, otherwise a bug in the way minecraft deals with block updates causes it to start and stop immediatly isPlaying = false; //since were stoping it we set this to false to say the sound is no longer playing this.shouldStop = shouldStop; } } public boolean isPlaying() { //we use this to allow other classes to see if were playing or not return isPlaying; } //here i need to build my gui and setup the nbt tags to allow persistence } the looping sound handler that will only ever be used by the above tileentity public class AlarmHandler2 extends MovingSound { private final TileEntity tileentity; private TileEntitySpeaker tileSpeaker; //again we make a value that will be used to get information from public AlarmHandler2(TileEntity tile, String Soundname) { //we are taking in the tile entity and the sound name super(new ResourceLocation(Reference.MODID + ":" + Soundname)); //setting the location of the sound file this.tileentity = tile; //we tell it that tileentity is the TileEntity we passed it on creating this instance this.repeat = true; //we say that we want the sound to repeat volume = 2f; //we hard code the volume....i need to actually pass it the volume i just forgot that untill this comment but meh thats easy, will do it later this.xPosF = tileentity.xCoord; //so were getting the location of the tile entity and putting them into values that the sound player WILL use (where i went wrong before) this.yPosF = tileentity.yCoord; this.zPosF = tileentity.zCoord; tileSpeaker = (TileEntitySpeaker) tileentity; // since we know that the TileEntity is going to be a TileEntitySpeaker we can safely cast this variable as one } public void update() { //this is run every tick // LogHelper.info("i should be making noise oh and volume is " + volume); //this is designed to give me feedback when debuging...its invaluable! if (tileSpeaker.isShouldStop()) { //ok so each tick we are looking at the speaker tile entity to see if we should stop or not //LogHelper.info("ok ill shut up now"); this.donePlaying = true; //stop making that awful noise we say } } @Override public boolean isDonePlaying() { return this.donePlaying; } //this is how the sound manager checks to see if it can shut the hell up yet } This all works just need to : (note im not asking how, though tips are appreciated) texture the block (easy) figure out how to change the texture when active with out resorting to meta data (hmm have an idea where to look) set some nbt tags up to store the data that needs to be persistant (meh no problem, very easy) create a gui that lists all values in an array, allows you to click on one to select it which it then writes to a string and also has a place to type in an int for volume (**GULP**)
×
×
  • Create New...

Important Information

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