Jump to content

lexwebb

Members
  • Posts

    56
  • Joined

  • Last visited

Everything posted by lexwebb

  1. That's pretty cool . I was going to do something pretty similar, but then i sas iChuns Sync mod and thought it would be freaking cool if the item were to build in front of you, which this will! The overall aim is to have it build pixel by pixel into the full item.
  2. Well, i found out a better way of doing it, i am now using a single white texture and am coloring each pixel using glColor4d. This, quite handily takes the alpha values from my textures, so now all i have to do is literally plug the texture in and it renders . Thanks for your help Draco!
  3. I'm trying to render 16*16 individual cube models with different textures all at once, that's 256 texture sets... This is causing me horrendous amounts of lag, ie. 3FPS when i usually get 150+. I cant quite work out why its taking SO MUCH time to reset the textures each time. for(int xPos = 0; xPos < 16; xPos++){ for(int yPos = 0; yPos < 16; yPos++){ GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); Opticraft.textureLoader.loadTexture(imageList[xPos][yPos]); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glScalef(0.5f, 0.5f, 0.5f); GL11.glTranslatef(0.1f * xPos, 0.1f * yPos, 0.0f); cModel.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); GL11.glPopMatrix(); } } I've a custom texture loader that borrows some inner functions from Minecraft TextureUtil's in my TextureLoader: public void loadTexture(BufferedImage bufferedimage){ try { boolean flag = false; boolean flag1 = false; TextureUtil.uploadTextureImageAllocate(this.getGlTextureId(), bufferedimage, flag, flag1); if (inputstream != null) { inputstream.close(); } } catch (IOException ex){ ex.printStackTrace(); } } This basically bypasses the Resource Location setting, so if anything, should be quicker than setting from resourceLocation. Is this a really stupid way of doing things? There are a few different ways i can do what i'm trying to do, but this would be my preferred.
  4. Because he doesn't texture the blocks, he only textures the full biped. + he's using skins, not item textures.
  5. Well i'm basically making a 3D printer, i need direct access to the .png's to be able to get each pixel of the images colour, which will be used to create a dynamic texture for a model that represents one pixel. These pixel blocks will be slowly built up by the printer, Similar to the Sync mod builds its player modes, except i want mine to be coloured in relation to the item being printed. I don't want to link directly through to assets, as i will have to make a long list containing the data of which .png links to which Item, and if I want to dynamically add mod items, that isn't going to work.
  6. I've had VERY simillar issues with trying to get transparent textures working on my tileEntity's. I've been looking into this but haven't found anything yet, I'm going to keep an eye out on this thread in case you find a solution, of course ill post what i've done if i get it to work
  7. yes thanks that does allow me to get the icon. My real need is to get a direct path to the .png file, do you know how i can get that from an Icon?
  8. Is it possible to get the Resource I.e texture of any item without making a specific reference inside the class? Preferably i'd need to be able to get the resource or ResourceLocation of any item, be it vanilla or a mod item. If i cannot do this, is there an easy way to get the associated .png of an Item. I've tried looking around in the RenderManager but haven't had much luck.
  9. I need to be able to sync an item selected in the clients GUI to an ItemStack inside my TileEntity. I have created a packet sending method inside my Container: public void sendSelectedItemPacket(){ ByteArrayOutputStream bos = new ByteArrayOutputStream(; DataOutputStream outputStream = new DataOutputStream(bos); try { outputStream.writeUTF("ItemSelect"); outputStream.write(tile_entity.xCoord); outputStream.write(tile_entity.yCoord); outputStream.write(tile_entity.zCoord); NBTTagCompound par1NBTTagCompound = new NBTTagCompound(); par1NBTTagCompound = selectedItem.writeToNBT(par1NBTTagCompound); String temp = par1NBTTagCompound.getName(); byte[] itemStackByte = par1NBTTagCompound.getByteArray(temp); outputStream.writeUTF(par1NBTTagCompound.getName()); outputStream.writeInt(itemStackByte.length); outputStream.write(itemStackByte); } catch (Exception ex) { ex.printStackTrace(); } Packet250CustomPayload packet = new Packet250CustomPayload(); packet.channel = (ModInfo.CHANNEL + "GuiSync"); packet.data = bos.toByteArray(); packet.length = bos.size(); PacketDispatcher.sendPacketToServer(packet); } This should (i hope) encode my selected items data to an NBTTag then byte array and send it through. I'm then re-making the item on the server using this method: private void handleItemSelectPacket(Packet250CustomPayload payload) { DataInputStream data = new DataInputStream(new ByteArrayInputStream(payload.data)); try { String temp = data.readUTF(); int byteLength = data.readInt(); byte[] itemStackByte = new byte[byteLength]; int x = data.readInt(); int y = data.readInt(); int z = data.readInt(); String compundName = data.readUTF(); data.read(itemStackByte); NBTTagCompound par1NBTTagCompound = new NBTTagCompound(); par1NBTTagCompound.setByteArray(compundName, itemStackByte); ItemStack iStack = ItemStack.loadItemStackFromNBT(par1NBTTagCompound); // MinecraftServer.getServer().get } catch (IOException e) { e.printStackTrace(); return; } } As you can probably see i'm not doing anything with the data i receive, as i cannot work out how to get a reference to the world > tileEntity from the data i receive in the packet. How would i go about getting that reference, or if there is an entirely better way of doing this then please let me know
  10. Descriptive comment for isBlockIndirectlyGettingPowered() is: 'Used to see if one of the blocks next to you or your block is getting power from a neighboring block. Used by items like TNT or Doors so they don't have redstone going straight into them. Args: x, y, z.' Your block is probably getting indirectly powered by the ones underneath them. You could try checking in the repeater class for how it detects its direct power.
  11. Awesome it works Thanks! The only thing i'm having issues with now is that it seems to be randomly rotated each time the game starts again. I'm setting the age to 0 every time so i'm not to sure what its about.
  12. Ah awesome thanks. Would you mind explaining where you are getting 'es.rotation' from, as i cannot seem to find a reference to it anywhere, and passing an arbitrary value in its place just seems to make the item spin uncontrollably.
  13. So i'm making a 3D printer block, so as you can imagine ill be needing to render the item i'm printing on the printing bed of the machine. I've experimented calling an ItemRenderer with bad results. Whats the best way to render an item like this in world? Would it be best to use an ItemEntity and somehow stop the rotation and make it un-pickupable? Or is there some way i can piggyback the ItemRenderer for an item as render it in my TileEntitySpecialRenderer?
  14. How large is the amount of data you will need to be storing for your leveling system? If you are having multiple abilities with different levels (I.e lots pf data per player) it would probably wise to integrate the server side of your Mod with a database system. E.g MySql. Otherwise, you could write a configuration file per player to a folder in the mods directory, which would be in a standard format and would simply store your player level data that way. There is also a handy tutorial i found for adding extra data to a player. E.g custom levels. this tutorial uses mana as an example, but i'm sure you could adapt it to your needs. (Post 2) http://www.minecraftforum.net/topic/1952901-eventhandler-and-iextendedentityproperties/http://www.minecraftforum.net/topic/1952901-eventhandler-and-iextendedentityproperties/
  15. Opps! Try now! I've added the color and and another piece of code i found elsewhere. (See code below below) now it kinda works... GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); GL11.glColor4f(1, 1, 1, 1); this.model.renderPipe((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glDisable(GL11.GL_BLEND);
  16. I have an odd issue when anything i render using GL11.GL_BLEND will become transparent and nontransparent depending on which way you look at it. An example can be seen in the video below. where the item in my hand will randomly switch states. The whole structure next to is meant to be transparent to. And look like this. but at the time of recording it was refusing to render transparent at all. Some sample render code: @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(0.0f, 1.4f, 0.0f); ResourceLocation textures = (new ResourceLocation(ModInfo.ID.toLowerCase() + ":textures/blocks/ColliderPipeCornerTile.png")); Minecraft.getMinecraft().renderEngine.bindTexture(textures); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); this.model.renderFrame((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glEnable(GL11.GL_BLEND); this.model.renderPipe((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); GL11.glPopMatrix(); }
  17. Have a look at ForgeChunkManager. There may be a few methods in there that will help
  18. Awesome, both replies will fulfill all my needs . I have one question regarding @Optional though. If i am using an API i.e buildcraft power; would i use the api name where the modId is required. For example @Interface(iface = "IPowerEmitter", modid = "BuildCraftAPI|power") This seems to want a ModId, which im not sure if API's use in the same way.
  19. So i need to include the buildcraft API to be able to transform power in my mod. I can reference and use the API fine in my workspace. But the way its currently implemented, it will not work if buildcraft is not installed. I am aware that i will probably need to use reflection, however i am unsure about how i would go about reflection interfaces that need to be implemented.. Does anyone have any example code, or a guide anywhere? I can't seem to find anything on Google.
  20. Similarly to how a beacon works, i need to be able to render my TileEntity when its hitbox is not in the camera view. I was unable to work out from the beacon code how it shows its beacon beam when the tile itself is not in view. Does anyone know how it does it?
  21. Welp i found he source of the datawatcher null pointers i was having. You can ignore that bit
  22. @diesieben07 When i tried using the inherited datawatcher i was getting NULL pointer exceptions thrown on the very first line i tried to use it. When debugging, i found that nothing was NULL, so i had no idea what was going on. I then decided to implement the datawatcher how i found in a tutorial which seemed to resolve the errors. I'll have a closer look at it. Even still, the fact the the datawatcher may not work does not explain the fact that my entity does never update.
  23. So, I'm trying to use a custom entity to render lasers, i have entity variable syncing working using the datawatcher and my client seems receiving the necessary coordinates for its laser rendering, however my onUpdate never gets called for this entity, so none of my code ever gets hit. What am i doing wrong? Entity is spawned from inside a TileEntity (My Laser) if (!worldObj.isRemote){ laserBeam(); } public void laserBeam(){ if(laserToList != null && laserToList.size() > 1){ for(int j = 0; j < laserToList.size() - 1; j++){ ForgeDirection or = laserToDirection.get(j); System.out.println("spawningLaser"); EntityBeam beam = new EntityBeam(worldObj, laserToList.get(0), laserToList.get(1)); worldObj.spawnEntityInWorld(beam); beam.updateDataServer(); laserToList.clear(); } } } The Entity package opticraft.entitys; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.util.List; import cpw.mods.fml.common.network.PacketDispatcher; import opticraft.lib.ModInfo; import opticraft.lib.Position; import net.minecraft.entity.DataWatcher; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class EntityBeam extends Entity { public List<Position> laserToList; public World world; public Position start, end; private DataWatcher dw; public EntityBeam(World par1World) { super(par1World); this.world = par1World; } public EntityBeam(World par1World, Position start, Position end) { super(par1World); this.start = start; this.end = end; this.dw = this.getDataWatcher(); this.dw.addObject(8, 0); this.dw.addObject(9, 0); this.dw.addObject(10, 0); this.dw.addObject(11, 0); this.dw.addObject(12, 0); this.dw.addObject(13, 0); System.out.println("EntityBeamInitialised, start: " + start.toString() + " - " + end.toString()); } @Override public void onUpdate() { if (!worldObj.isRemote) { updateDataServer(); System.out.println("UpdatedServer"); } if (worldObj.isRemote) { updateDataClient(); System.out.println("UpdatedClient"); } if (this.ticksExisted > 5) { this.setDead(); } boundingBox.minX = Math.min(start.x, end.x); boundingBox.minY = Math.min(start.y, end.y); boundingBox.minZ = Math.min(start.z, end.z); boundingBox.maxX = Math.max(start.x, end.x); boundingBox.maxY = Math.max(start.y, end.y); boundingBox.maxZ = Math.max(start.z, end.z); boundingBox.minX--; boundingBox.minY--; boundingBox.minZ--; boundingBox.maxX++; boundingBox.maxY++; boundingBox.maxZ++; super.onUpdate(); } @Override protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { // TODO Auto-generated method stub } @Override protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { // TODO Auto-generated method stub } protected void updateDataClient() { start.x = decodeDouble(dw.getWatchableObjectInt(); start.y = decodeDouble(dw.getWatchableObjectInt(9)); start.z = decodeDouble(dw.getWatchableObjectInt(10)); end.x = decodeDouble(dw.getWatchableObjectInt(11)); end.y = decodeDouble(dw.getWatchableObjectInt(12)); end.z = decodeDouble(dw.getWatchableObjectInt(13)); } protected void updateDataServer() { if (!worldObj.isRemote) { System.out.println("lolwut"); } dw.updateObject(8, Integer.valueOf(encodeDouble(start.x))); dw.updateObject(9, Integer.valueOf(encodeDouble(start.y))); dw.updateObject(10, Integer.valueOf(encodeDouble(start.z))); dw.updateObject(11, Integer.valueOf(encodeDouble(end.x))); dw.updateObject(12, Integer.valueOf(encodeDouble(end.y))); dw.updateObject(13, Integer.valueOf(encodeDouble(end.z))); } protected int encodeDouble(double d) { return (int) (d * 8192); } protected double decodeDouble(int i) { return (i / 8192D); } @Override protected void entityInit() { // TODO Auto-generated method stub } } Main Mod Class EntityRegistry.registerModEntity(EntityBeam.class, "EntityBeam", 23, this, 128, 1, false); If there's any more code you need to see you can find it on my GitHub https://github.com/lexwebb/opticraft
×
×
  • Create New...

Important Information

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