Jump to content

TheMCJavaFre4k

Members
  • Posts

    84
  • Joined

  • Last visited

Everything posted by TheMCJavaFre4k

  1. I can't seem to get it to look in the custom resource file, It just keep looking in the resources for the mod.
  2. so i just use something like: new ResourceLocation("ModAssets", nameOfFile)
  3. so I've got it pointed to another folder called ModAssets within the .minecraft folder and within that i have the standard file system of assets/modid/sounds etc.. but how do i then use this new FolderResourcePack in a resource location? Im trying to eliminate the need for people to head into the resource pack option and choose the mod one just for simplicity.
  4. because in the custom block I'm creating, it will have its own gui to allow the player to play sounds and do all these things, not just replace the base minecraft ones.
  5. I was using just a folder but i can't anymore hence why I'm stuck at the moment. Im wanting people to be able to dump images and sounds into a file within .minecraft then in game can use custom blocks to either play the sounds or use the textures etc.
  6. Well i was using the mods folder back in 1.6.4 as the assets because the mod could be run as a folder and thats just the code i was following. I will probably move it to a seperate file if i know it works.
  7. I think I've got more of an understanding now. What i have so far: public void registerResources(){ List<IResourcePack> defaultResourcePacks = null; defaultResourcePacks = ReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks"); defaultResourcePacks.add(new FolderResourcePack(new File("/mods"))); } Im not sure if this is working because I'm not entirely sure how to use this now to load an asset.
  8. I'm totally lost now. So ill look into reflection as i haven't used the technique before and have no clue what to do unless i know it by a different name. And if I'm using IResourcePack now, how do i specify the root folder?
  9. How to i access the list? What class is it in.
  10. How would i go about performing the latter. Ive got a new FolderResourcePack pain ting to my root folder.
  11. Ive just started modding again since 1.6.4 and I'm trying to figure out how i would go about reading a file and loading assets from an external locations such as another file in the mods folder. Ive seen a few posts saying that you need to either create a class that implements IResourceManager or to use FolderResourcePack to set a folder as a default resource pack location. From my understanding, the FolderResourcePack should be ideal as i am following the normal minecraft resource layout of Directory/assets/modid/textures.. etc. Im just not sure where to start with using FolderResourcePack as I've always been used to just using standard directories as the mods never used to be packaged. Could anyone show me a barebones way of doing this or point me in the right direction. Thanks
  12. So I'm drawing this in a custom Item Render where it renders the model and the posX, posY, posZ are from EntityPlayer.pos.... So i would replace the pos... to 0, 0, 0, and subtract the pos.. from the block coords?
  13. Well I'm not sure if i get what your wanting 100% but i think your trying to rewrite the file correct? As far as i know you can't. The way i would do it is delete the file using built in java io then rewrite the whole config file again with a setBoolean(true), Mabye. Once again - I'm not sure if this is what you wanted or wether you can or not but this is how i would do it.
  14. Sorry to bring this back but I've been trying to spawn a line form player position to the crosshair of the player or the block the player is looking at; Ive got this so far: Vec3 lookPos = Entityplayer.getLookVec(); MovingObjectPosition Coord = Entityplayer.rayTrace(300, 1); if(Coord != null){ GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1, 0, 0, 0.5F); // change this for your colour GL11.glLineWidth(10.0F); GL11.glDepthMask(false); Tessellator tessellator = Tessellator.instance; tessellator.startDrawing(GL11.GL_LINES); tessellator.addVertex(posX, posY, posZ); tessellator.addVertex(Coord.blockX, Coord.blockY, Coord.blockZ); tessellator.draw(); GL11.glDepthMask(true); GL11.glPopAttrib(); } } I thought this would work but it doesn't go to the block. I see it on the right side buts it looks like it is just a small length I think it may be the second vertex and the coords are not right?
  15. One more thing Is there anyway i can make these lines shine bright in dark areas or emit light. Doesn't matter if there isn't
  16. Yep all working now Thanks again
  17. Thanks for that - are the x1 y1 z1 and x2 y2 z2 the stat and end coords of the line? Also i can't seem to get the colour to work. Also thanks for that tutorial - I'm going to give it a read through for future needs EDIT: Ok i think I've got everything working great now. Thanks heaps
  18. So GL11 does have a method for a ray and then i use a renderer class to render it out correct? if found this: GL11.glBegin(GL11.GL_LINES); but not sure how to use it
  19. Hi Does anyone know if there are any GL11 methods to create coloured lines that look somewhat like lasers? If not how would i make one that looks like the build craft lasers? Im hoping its just say a gl11 draw line method or something.
  20. Once again Thanks for all your help - You have been a god send for me.
  21. Considering that its not a container that is Meant to store things in, Ill get by just setting the Contents in the guy swell. If i get the time i can always add the code to send to the client as well. Also one quick thing (as its just probably using the method already built in I don't think i should open another topic for this) How would i check the slot for a certain item, Would i just use : @Override public ItemStack getStackInSlot(int i) { return inv[i]; } or do i do something like: ItemStack e = ((TileEntityRecordingUnit) tile).getStackInSlot(0); if(e == new ItemStack(Item.appleGold, 1, 0)){ } If you can't help me with this its fine, You've helped me so much already, I can't thank you enough Thanks Soooooooo much for your help.
  22. Ive just checked if the item appears if the Gui is closed and reopened and it does, And its real item. Is that what the method you wrote stops?
  23. Ill add the system prints in and get back to you but ill post my container and Gui handler: Container: package net.PartyMod.GUI; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class ContainerRecordingUnit extends Container { protected TileEntityRecordingUnit tileEntity; public ContainerRecordingUnit (InventoryPlayer inventoryPlayer, TileEntityRecordingUnit te){ tileEntity = te; addSlotToContainer(new Slot(tileEntity, 0, 44 , 35)); bindPlayerInventory(inventoryPlayer); } @Override public boolean canInteractWith(EntityPlayer player) { return tileEntity.isUseableByPlayer(player); } protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int i = 0; i < 9; i++) { addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142)); } } @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot) { ItemStack stack = null; Slot slotObject = (Slot) inventorySlots.get(slot); if (slotObject != null && slotObject.getHasStack()) { ItemStack stackInSlot = slotObject.getStack(); stack = stackInSlot.copy(); if (slot < 9) { if (!this.mergeItemStack(stackInSlot, 0, 35, true)) { return null; } } //places it into the tileEntity is possible since its in the player inventory else if (!this.mergeItemStack(stackInSlot, 0, 9, false)) { return null; } if (stackInSlot.stackSize == 0) { slotObject.putStack(null); } else { slotObject.onSlotChanged(); } if (stackInSlot.stackSize == stack.stackSize) { return null; } slotObject.onPickupFromSlot(player, stackInSlot); } return stack; } } and my Gui handler: package net.PartyMod.GUI; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler { //returns an instance of the Container you made earlier @Override public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); if(tileEntity instanceof TileEntityRecordingUnit){ return new ContainerRecordingUnit(player.inventory, (TileEntityRecordingUnit) tileEntity); } return null; } //returns an instance of the Gui you made earlier @Override public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); if(tileEntity instanceof TileEntityRecordingUnit){ return new GuiRecordingUnit(player.inventory, (TileEntityRecordingUnit) tileEntity); } return null; } } Thanks
  24. ok - I've changed the integers even though i checked that they weren't being changed thru system prints Heres the tile entity code - I haven't changed this much at all really: package net.PartyMod.GUI; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; public class TileEntityRecordingUnit extends TileEntity implements IInventory { private ItemStack[] inv; public TileEntityRecordingUnit() { inv = new ItemStack[1]; } @Override public void closeChest() {} @Override public ItemStack decrStackSize(int i, int j) { ItemStack stack = getStackInSlot(i); if (stack != null) { if (stack.stackSize <= j) { setInventorySlotContents(i, null); } else { stack = stack.splitStack(j); if (stack.stackSize == 0) { setInventorySlotContents(i,null); } } } return stack; } @Override public String getInvName() { return "Recording Unit"; } @Override public int getInventoryStackLimit() { return 1; } @Override public int getSizeInventory() { return inv.length; } @Override public ItemStack getStackInSlot(int i) { return inv[i]; } @Override public ItemStack getStackInSlotOnClosing(int i) { ItemStack stack = getStackInSlot(i); if (stack != null) { setInventorySlotContents(i, null); } return stack; } @Override public boolean isInvNameLocalized() { // TODO Auto-generated method stub return false; } @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { // TODO Auto-generated method stub return false; } @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && entityplayer.getDistanceSq(xCoord+0.5, yCoord+0.5, zCoord+0.5) < 64; } @Override public void openChest() {} @Override public void setInventorySlotContents(int i, ItemStack itemstack) { inv[i] = itemstack; if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { itemstack.stackSize = getInventoryStackLimit(); } } @Override public void readFromNBT(NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); NBTTagList tagList = tagCompound.getTagList("Inventory"); for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(i); byte slot = tag.getByte("Slot"); if (slot >= 0 && slot < inv.length) { inv[slot] = ItemStack.loadItemStackFromNBT(tag); } } } @Override public void writeToNBT(NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); NBTTagList itemList = new NBTTagList(); for (int i = 0; i < inv.length; i++) { ItemStack stack = inv[i]; if (stack != null) { NBTTagCompound tag = new NBTTagCompound(); tag.setByte("Slot", (byte)i); stack.writeToNBT(tag); itemList.appendTag(tag); } } tagCompound.setTag("Inventory", itemList); } }
  25. This is my whole Gui class in which the packet is sent: package net.PartyMod.GUI; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import net.PartyMod.Common.Common; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import org.lwjgl.opengl.GL11; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.relauncher.Side; public class GuiRecordingUnit extends GuiContainer { public GuiTextField text; public boolean search = false; public int songCount = 0; public int discNo = 0; public int buttonPage = 0; public String searched = ""; protected TileEntityRecordingUnit tile; public GuiRecordingUnit (InventoryPlayer inventoryPlayer, TileEntityRecordingUnit tileEntity) { super(new ContainerRecordingUnit(inventoryPlayer, tileEntity)); tile = tileEntity; } @Override public void initGui(){ super.initGui(); Minecraft.getMinecraft().thePlayer.addChatMessage("Thing " + buttonPage); this.buttonList.clear(); for(int x = 0; x < 100; x++){ this.buttonList.clear(); if(buttonPage == 0){ for(int y = 0; y < 10; y++){ this.buttonList.add(new GuiButton(2 + y, guiLeft - 120 , guiTop + (y*18), 120, 17, Common.songs[y])); } } if(buttonPage == 1){ for(int y = 0; y < 10; y++){ this.buttonList.add(new GuiButton(10 + 2 + y, guiLeft - 120 , guiTop + (y*18), 120, 17, Common.songs[10 + y])); } } if(buttonPage == 2){ for(int y = 0; y < 10; y++){ this.buttonList.add(new GuiButton(20 + 2 + y, guiLeft - 120 , guiTop + (y*18), 120, 17, Common.songs[20 + y])); } } if(buttonPage == 3){ for(int y = 0; y < 10; y++){ this.buttonList.add(new GuiButton(30 + 2 + y, guiLeft - 120 , guiTop + (y*18), 120, 17, Common.songs[30 + y])); } } } this.buttonList.add(new GuiButton(0, guiLeft-120, guiTop - 21, 20, 20, "<")); this.buttonList.add(new GuiButton(1, guiLeft-20, guiTop - 21, 20, 20, ">")); text = new GuiTextField(fontRenderer, guiLeft + xSize + 14, guiTop + 15, 100, 13); text.setFocused(false); } public void keyTyped(char c, int i){ super.keyTyped(c, i); text.textboxKeyTyped(c, i); if(search = true){ searched = text.getText().toString(); } } public void mouseClicked(int i, int j, int k){ super.mouseClicked(i, j, k); text.mouseClicked(i, j, k); search = true; } public void actionPerformed(GuiButton b){ EntityPlayerMP playerEntity; switch(b.id){ case 0: if(buttonPage != 0){ buttonPage--; this.buttonList.clear(); this.initGui(); break; } case 1: if(buttonPage !=10){ buttonPage++; this.buttonList.clear(); this.initGui(); break; } } if(buttonPage == 0){ switch(b.id){ case 2: discNo = 1; this.constructPacket(tile, discNo); break; case 3: discNo = 2; break; case 4: break; case 5: break; case 6: break; case 7: break; case 8: break; case 9: break; case 10: break; case 11: break; case 12: break; } } } public void constructPacket(TileEntity te, int discNumber){ int PosX = te.xCoord; int PosY = te.yCoord; int PosZ = te.zCoord; ByteArrayOutputStream bos = new ByteArrayOutputStream(; DataOutputStream os = new DataOutputStream(bos); try { os.writeInt(PosX); os.writeInt(PosY); os.writeInt(PosZ); os.writeInt(discNo); } catch (Exception ex) { ex.printStackTrace(); } Packet250CustomPayload packet = new Packet250CustomPayload(); packet.channel = "PartyMod1"; packet.data = bos.toByteArray(); packet.length = bos.size(); PacketDispatcher.sendPacketToServer(packet); } @Override protected void drawGuiContainerForegroundLayer(int param1, int param2) { fontRenderer.drawString("Search For Songs", 195, 4, 1111111); fontRenderer.drawString("Recording Unit", 8, 6, 4210752); fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { ResourceLocation textureFile = new ResourceLocation(Common.modid.toLowerCase(), "textures/gui/recordingunit.png"); Minecraft.getMinecraft().getTextureManager().bindTexture(textureFile); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int x = (this.width - xSize) /2; int y = (this.height - ySize) /2; this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); text.drawTextBox(); } } If you need more just let me know
×
×
  • Create New...

Important Information

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