Jump to content

Kaneka

Members
  • Posts

    110
  • Joined

  • Last visited

Posts posted by Kaneka

  1. Hello everybody, 

     

    for my mod i need to store multiple "knowledges" to the player. These knowledges are only floats. 

    I implemented one knowledge as a capability with interface IKnowledge , implementation KnowledgeEnder, IStorage KnowledgeStorage, ICapabilitySerializable<NBTBase> KnowledgeEnderProvider and capabilityhandler.  

    It works fine.

    Now I need to know, how to add more knowledges right. I am not sure how to do it propably. 

    Just create the 6 classes mentioned above for each knowledge? Or just some of them? Or do it completly different with only one capability? 

    These knowledges will be used together sometimes and sometimes seperated from each other. 

     

    Thanks for every answer,

    Kaneka

     

     

  2. Hello everybody, 

     

    I am planning to make a mod that has a skill system as a main feature and i am not sure how to add this properly. I don´t want to mess around and just make it work, but not perfekt, it should be well done and not using forge features incorrectly. 

    There will be a new kind of level and exp for the player additional with skillpoints and a skilltree.  

    Are there any tips, hints, words for me or tutorials you would recommend?

     

    Thanks for every answer, 

    Kaneka

  3. my problem is that my mod add a doubling ore way by creating ore plants, these plants dont drop any seed, because then you have endless ingots and thats not what i want to. The right click mods(simple harvest, gentle harvest and so on) bypassed this and direktly replant them without checking if there is a seed or not.

    I have contacted some right click mod authors and they add the seedcheck. But these simple harvest mods are "easy" and because of that so many authors copy that idea and try to make their own. Now there are so much right click mod I can´t contact every author....

    So dependency wont work because I cant take any mod in my code

  4.  

    I am talking about a block.

    here is a example of the mods interactiong with my mod, how do I prevent them doing this?

    Source: https://github.com/sblectric/OpenHarvest/blob/master/src/main/java/sblectric/openharvest/events/HarvestEvents.java

    public class HarvestEvents {
    
    /** Harvest crops on this event */
    @SubscribeEvent
    public void onHarvestCrops(PlayerInteractEvent.RightClickBlock event) {
    	World world = event.getWorld();
    	if(world.isRemote) return; // do nothing on client thread
    
    	BlockPos pos = event.getPos();
    	IBlockState state = world.getBlockState(pos);
    	Block block = state.getBlock();
    	EntityPlayerMP ply = (EntityPlayerMP)event.getEntityPlayer();
    
    	// make sure the off-hand is active and right-clicking a crop block
    	if(event.getHand() == EnumHand.OFF_HAND && block instanceof BlockCrops) {
    
    		// make sure the block isn't blacklisted
    		ResourceLocation name = block.getRegistryName();
    		String modid = name.getResourceDomain();
    		if(!HarvestConfig.modBlacklist.contains(modid) && !HarvestConfig.blockBlacklist.contains(name.toString())) {
    
    			// get the age type
    			PropertyInteger age = null;
    			int maxAge = -1;
    			for(IProperty prop : state.getPropertyNames()) {
    				if(prop instanceof PropertyInteger && prop.getName().equals("age")) {
    					age = (PropertyInteger)prop;
    					maxAge = HarvestUtils.max(age.getAllowedValues());
    					break;
    				}
    			}
    
    			// make sure the age property is valid
    			if(age != null && maxAge > -1) {
    				if(state.getValue(age) == maxAge) {
    					for(ItemStack s : block.getDrops(world, pos, state, 0)) {
    						ply.inventory.addItemStackToInventory(s);
    					}
    					world.setBlockState(pos, block.getDefaultState());
    				}
    			}
    
    		}
    	}
    }
    }
    

  5. Hi everyone,

     

    is there any way to prevent other mods from interacting with some of my blocks? In my situation i need to prevent the right clicking mods because they cause a abuse of a modfeature.

    I suscribed at already at the event to cancel it, with highest priority, but the right clicking mod do this too...And then my suscribed event only works when my event is fired befor the other mods.

    Is there any better way doing this?

     

    thanks for every answer,

     

    Kaneka

  6. public class MultiAssemblerTESR extends TileEntitySpecialRenderer<TileEntityMultiAssembler>
    {
    @Override
    public void renderTileEntityAt(TileEntityMultiAssembler te, double x, double y, double z, float partialTicks, int destroyStage) 
    {
    
            int teposX = te.getPos().getX();
            int teposY = te.getPos().getY();
            int teposZ = te.getPos().getZ();
            Map list = te.getBlocksWithMarkersList();
    	Entity entity = this.rendererDispatcher.entity;
    	double distance = te.getDistanceSq(entity.posX, entity.posY, entity.posZ);
        if (distance < 100.0 && !list.isEmpty()) 
        {
        	
        	 Iterator iterator = list.entrySet().iterator();
             Entry entry;
             do
             {
                 entry = (Entry)iterator.next();
                 BlockPos actualpos = (BlockPos) entry.getKey();
                 drawCubeWithCrossesAtPos(x, y, z, actualpos.getX() - teposX, actualpos.getY() - teposY, actualpos.getZ() - teposZ);
                 
             }
             while (iterator.hasNext());
    	}
    
    }
    
    public static void drawCubeWithCrossesAtPos(double x, double y, double z, int addx, int addy, int addz)
    {
    	GL11.glPushMatrix();
    	GlStateManager.color(1F, 0F, 0F);
    	GlStateManager.glLineWidth(10F);
    	GL11.glTranslated(x + addx, y + addy, z + addz);
    	 Tessellator tessellator = Tessellator.getInstance();
    	 VertexBuffer worldRenderer = tessellator.getBuffer();
    	 int rendertype = GL11.GL_LINE_STRIP;
    	//CrossNorth
    		worldRenderer.begin(rendertype, DefaultVertexFormats.POSITION);
    		worldRenderer.pos(0, 0, -0.001).endVertex();
    		worldRenderer.pos(1, 1, -0.001).endVertex();
    		worldRenderer.pos(1, 0, -0.001).endVertex();
    		worldRenderer.pos(0, 1, -0.001).endVertex();
    		tessellator.draw();
    		//CrossWest
    		worldRenderer.begin(rendertype, DefaultVertexFormats.POSITION);
    		worldRenderer.pos(-0.001, 0, 1).endVertex();
    		worldRenderer.pos(-0.001, 1, 0).endVertex();
    		worldRenderer.pos(-0.001, 0, 0).endVertex();
    		worldRenderer.pos(-0.001, 1, 1).endVertex();
    		tessellator.draw();
    		//CrossSouth
    		worldRenderer.begin(rendertype, DefaultVertexFormats.POSITION);
    		worldRenderer.pos(1, 0, 1.001).endVertex();
    		worldRenderer.pos(0, 1, 1.001).endVertex();
    		worldRenderer.pos(0, 0, 1.001).endVertex();
    		worldRenderer.pos(1, 1, 1.001).endVertex();
    		tessellator.draw();
    		//CrossEast
    		worldRenderer.begin(rendertype, DefaultVertexFormats.POSITION);
    		worldRenderer.pos(1.001, 0, 0).endVertex();
    		worldRenderer.pos(1.001, 1, 1).endVertex();
    		worldRenderer.pos(1.001, 0, 1).endVertex();
    		worldRenderer.pos(1.001, 1, 0).endVertex();
    		tessellator.draw();
    		//CrossUp
    		worldRenderer.begin(rendertype, DefaultVertexFormats.POSITION);
    		worldRenderer.pos(1, 1.001, 1).endVertex();
    		worldRenderer.pos(0, 1.001, 0).endVertex();
    		worldRenderer.pos(0, 1.001, 1).endVertex();
    		worldRenderer.pos(1, 1.001, 0).endVertex();
    		tessellator.draw();
    		//CrossDown
    		worldRenderer.begin(rendertype, DefaultVertexFormats.POSITION);
    		worldRenderer.pos(1, -0.001, 1).endVertex();
    		worldRenderer.pos(0, -0.001, 0).endVertex();
    		worldRenderer.pos(0, -0.001, 1).endVertex();
    		worldRenderer.pos(1, -0.001, 0).endVertex();
    		tessellator.draw();
    		//RestUp
    		worldRenderer.begin(rendertype, DefaultVertexFormats.POSITION);
    		worldRenderer.pos(1, 1.001, 1).endVertex();
    		worldRenderer.pos(1, 1.001, 0).endVertex();
    		worldRenderer.pos(0, 1.001, 0).endVertex();
    		worldRenderer.pos(0, 1.001, 1).endVertex();
    		worldRenderer.pos(1, 1.001, 1).endVertex();
    		tessellator.draw();
    		//RestDown
    		worldRenderer.begin(rendertype, DefaultVertexFormats.POSITION);
    		worldRenderer.pos(1, -0.001, 1).endVertex();
    		worldRenderer.pos(1, -0.001, 0).endVertex();
    		worldRenderer.pos(0, -0.001, 0).endVertex();
    		worldRenderer.pos(0, -0.001, 1).endVertex();
    		worldRenderer.pos(1, -0.001, 1).endVertex();
    		tessellator.draw();
    		GL11.glPopMatrix();
    
    }
    }
    

  7. Thanks a lot, this is my solution:

     

    @SideOnly(Side.CLIENT)
    static class ModeButton extends GuiButton
    {
    	private int mode; 
    	private IInventory inv; 
        public ModeButton(int parButtonId, int parPosX, int parPosY, IInventory inventory)
        {
            super(parButtonId, parPosX, parPosY, 18, 18, "");
            this.mode = inventory.getField(2);
            this.inv = inventory;
        }
    
        
        @Override
    	public void drawButton(Minecraft mc, int parX, int parY)
        {
             	this.mode = inv.getField(2);
        		GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        	    mc.renderEngine.bindTexture(BACKGROUND);
        	    int xstart = (90 + 18 * mode);
                drawModalRectWithCustomSizedTexture(xPosition, yPosition, xstart, 225, 18, 18 , 512F, 512F);
        }
        
        
    }
    

  8. I did, and it works fine, but dont update the texture of the button when clicked.

     

    @SideOnly(Side.CLIENT)
    static class ModeButton extends GuiButton
    {
    	private int mode; 
        public ModeButton(int parButtonId, int parPosX, int parPosY, IInventory inventory)
        {
            super(parButtonId, parPosX, parPosY, 18, 18, "");
            this.mode = inventory.getField(2);
        }
    
        
        @Override
    	public void drawButton(Minecraft mc, int parX, int parY)
        {
             	
        		GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        	    mc.renderEngine.bindTexture(BACKGROUND);
        	    int xstart = (90 + 18 * mode);
                drawModalRectWithCustomSizedTexture(xPosition, yPosition, xstart, 225, 18, 18 , 512F, 512F);
        }
        
        
    }
    

  9. Hi everyone,

     

    I have a GuiContainer with buttons, and one button defines in witch "mode" the tileentity is.

    The texture of the button is connected to the TE, so when I open the GUI, the button have the right texture, but I want the button to change the texture when clicking on it, not just when I close the Gui and open it again. 

    Is there any method i didn´t see? Can someone help me?

     

    Thanks for every answer.

     

    Kaneka

  10. Hi

     

    If you are looking for something like this:

    then you'll probably find RenderWorldLastEvent event useful.

    In the event, use the Tessellator to draw your markers, for example something along these lines, where the [x1,y1,z1] etc define the four corners of a square just in front of the face you're drawing, and you repeat this method for all faces of every cube you want to outline:

     

      public static void drawBoxWithCross(double x1, double x2, double x3, double x4,
                                          double y1, double y2, double y3, double y4,
                                          double z1, double z2, double z3, double z4)
      {
        Tessellator tessellator = Tessellator.getInstance();
        WorldRenderer worldRenderer = tessellator.getWorldRenderer();
        worldRenderer.startDrawing(GL11.GL_LINE_STRIP);
        worldRenderer.addVertex(x1, y1, z1);
        worldRenderer.addVertex(x2, y2, z2);
        worldRenderer.addVertex(x3, y3, z3);
        worldRenderer.addVertex(x4, y4, z4);
        worldRenderer.addVertex(x1, y1, z1);
        tessellator.draw();
    
        worldRenderer.startDrawing(GL11.GL_LINES);
        worldRenderer.addVertex(x1, y1, z1);
        worldRenderer.addVertex(x3, y3, z3);
        worldRenderer.addVertex(x2, y2, z2);
        worldRenderer.addVertex(x4, y4, z4);
        tessellator.draw();
      }
    

    That code was for 1.8 so it might be slightly different now, but it gives you the basic idea?

     

    -TGG

     

    Isn´t this some way doing it? All I need to know is where to call this method, and what I need to do additionally to make it work.  I never worked with openGL or RenderWorldLastEvent. Thats my problem.

×
×
  • Create New...

Important Information

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