Jump to content

Emax

Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by Emax

  1. Hi, i'm trying to make a camouflage block with a TileEntitySpecialRenderer

     

     

     

    This is the code (copied from http://www.minecraftforge.net/forum/index.php?topic=11397.msg59091#msg59091, just for an experiment) :

            @Override
    public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) {
    
    	if (tileEntity instanceof MyTileEntity) {
    
    		Block block = Blocks.dirt; // i just trying dirt
    
    		if (block != null) {
    			RenderHelper.disableStandardItemLighting();
    
    			GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    			GL11.glEnable(GL11.GL_BLEND);
    
    			if (Minecraft.isAmbientOcclusionEnabled()) {
    				GL11.glShadeModel(GL11.GL_SMOOTH);
    			} else {
    				GL11.glShadeModel(GL11.GL_FLAT);
    			}
    
    			GL11.glPushMatrix();
    			GL11.glTranslated(d0, d1, d2);
    
    			Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("minecraft", "textures/blocks/dirt.png")); // bind dirt
    
    			Tessellator tessellator = Tessellator.instance;
    			tessellator.startDrawingQuads();
    			RenderBlocks renderBlocks = new RenderBlocks(tileEntity.getWorldObj());
    			tessellator.setTranslation(-te.xCoord, -te.yCoord, -te.zCoord);
    			renderBlocks.renderBlockByRenderType(block, te.xCoord, te.yCoord, te.zCoord);
    			tessellator.draw();
    			tessellator.setTranslation(0, 0, 0);
    			GL11.glPopMatrix();
    
    			RenderHelper.enableStandardItemLighting();
    		}
    	}
    }
    

     

    This is what happens:

    6c3982208e.png

  2. This should work

     

    public static void loadBind(BufferedImage image) {
    
    	int[] pixels = new int[image.getWidth() * image.getHeight()];
    
    	image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0, image.getWidth());
    
    	ByteBuffer buffer = BufferUtils.createByteBuffer(image.getWidth() * image.getHeight() * BYTES_PER_PIXEL);
    
    	for (int y = 0; y < image.getHeight(); y++) {
    		for (int x = 0; x < image.getWidth(); x++) {
    			int pixel = pixels[y * image.getWidth() + x];
    			buffer.put((byte) ((pixel >> 16) & 0xFF));
    			buffer.put((byte) ((pixel >>  & 0xFF));
    			buffer.put((byte) (pixel & 0xFF));
    			buffer.put((byte) ((pixel >> 24) & 0xFF));
    		}
    	}
    
    	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, image.getWidth(), image.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer) buffer.flip());
    }
    

  3. Hi, i'm developing a client mod i'm searching for a event that is called when the player join the server

    and after he joins automatically send a chat message, i tried this code, but throw a NullPointerException when getting the player

     

    	
           @SubscribeEvent
    public void onConnectedToServerEvent(ClientConnectedToServerEvent event) {
    	EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
            player.sendChatMessage("Hello!"); // <-- NullPointerException
    }
    

×
×
  • Create New...

Important Information

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