Jump to content

lyghtningwither

Members
  • Posts

    38
  • Joined

  • Last visited

Posts posted by lyghtningwither

  1. I am a precisionist. I must have everything colored the right way. So that's why I created the RGB block: for people like me who aren't satisfied with Minecraft's 14 or so default colors and want to be able to have all 4,294,967,296 possible RGBA colors. But I've run into a big problem. I can't figure out how to color it. It is, by default, black. I am using a TileEntitySpecialRenderer. I know my tile entity's R, G, B & A values are being set (I printed them out to the console). The way they are set is kind of like a sign, as when you place it a screen pops up prompting you to enter in the RGBA values. Then the TESR takes those values in, binds a white texture, renders the model, and calls GLStateManager.color, using the TileEntityRgb's R, G, B & A values divided by 255 (as they're 0-255), and then calls pop matrix and all that stuff. But for some reason, it's still only placing black. The lighting and everything is working, it just isn't setting the correct texture. Attached is a screenshot of a block that should've been a transparent, light blue.

    Here is my code for the TESR:

    private static final ResourceLocation TEXTURE = new ResourceLocation(Reference.MOD_ID + ":textures/blocks/rgb.png");
    	private final ModelRgbBlock MODEL = new ModelRgbBlock();
    	
    	@Override
    	public void render(TileEntityRgb te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    		
    		GlStateManager.enableDepth();
            GlStateManager.depthFunc(515);
            GlStateManager.depthMask(true);
        	
        	ModelRgbBlock model = MODEL;
        	
        	if (destroyStage >= 0) {
        		
                this.bindTexture(DESTROY_STAGES[destroyStage]);
                GlStateManager.matrixMode(5890);
                GlStateManager.pushMatrix();
                GlStateManager.scale(4.0F, 4.0F, 1.0F);
                GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
                GlStateManager.matrixMode(5888);
            } else this.bindTexture(TEXTURE);
        	
        	GlStateManager.pushMatrix();
            GlStateManager.enableRescaleNormal();
            GlStateManager.translate((float)x, (float)y + 1.0F, (float)z + 1.0F);
            GlStateManager.scale(1.0F, -1.0F, -1.0F);
            GlStateManager.translate(0.5F, 0.5F, 0.5F);
            GlStateManager.translate(-0.5F, -0.5F, -0.5F);
           
            model.renderAll();
            GlStateManager.color(te.r / 255, te.g / 255, te.b / 255, te.a / 255);
            GlStateManager.disableRescaleNormal();
            GlStateManager.popMatrix();
    
            if (destroyStage >= 0) {
            	
                GlStateManager.matrixMode(5890);
                GlStateManager.popMatrix();
                GlStateManager.matrixMode(5888);
            

    By the way, renderAll() is just a function that renders without the need for entity variables and all that stuff that isn't needed just to render a cube.

    I don't know what's going on with this code, so please, if you could, point me in the right direction on what I need to do. Thanks in advance!

    2018-12-26_17.38.38.png

  2. By the way, here is my code:

    @Override
        @SideOnly(Side.CLIENT)
        public void renderInventoryEffect(int x, int y, PotionEffect effect, Minecraft mc) {
    		
            this.render(x + 6, y + 7, 1);
        }
    	
        @Override
        @SideOnly(Side.CLIENT)
        public void renderHUDEffect(int x, int y, PotionEffect effect, Minecraft mc, float alpha) {
        	
            this.render(x + 3, y + 3, alpha);
        }
        
        @SideOnly(Side.CLIENT)
        private void render(int x, int y, float alpha) {
        	
            Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(Reference.MOD_ID + ":textures/gui/potion_effects.png"));
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder buf = tessellator.getBuffer();
            buf.begin(7, DefaultVertexFormats.POSITION_TEX);
            GlStateManager.color(1.0F, 1.0F, 1.0F, alpha);
            int textureX = this.getStatusIconIndex() % 8 * 18;
            int textureY = 198 + this.getStatusIconIndex() / 8 * 18;
            buf.pos(x, y + 18, 0).tex(textureX * 0.00390625, (textureY + 18) * 0.00390625).endVertex();
            buf.pos(x + 18, y + 18, 0).tex((textureX + 18) * 0.00390625, (textureY + 18) * 0.00390625).endVertex();
            buf.pos(x + 18, y, 0).tex((textureX + 18) * 0.00390625, textureY * 0.00390625).endVertex();
            buf.pos(x, y, 0).tex(textureX * 0.00390625, textureY * 0.00390625).endVertex();
            tessellator.draw();
        }

     

  3. I'm making some potion effects, and I'm trying to make an icon for them for when you have the effect on. Here is my code for getting the image from the file:

     

    public BasePotion(String name, boolean badPotion, int color, int iconIndexX, int iconindexY) {
    		
    		super(badPotion, color);
    		setPotionName("effect." + name);
    		setIconIndex(iconIndexX, iconindexY);
    		setRegistryName(new ResourceLocation(Reference.MOD_ID + ":" + name));
    	}
    	
    	@Override
    	public boolean hasStatusIcon() {
    		
    		Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(Reference.MOD_ID + ":textures/gui/potion_effects.png"));
    		return true;
    	}

    (I basically copied the whole class, but I feeled like it was needed to see the constructor as well.)

    I have potions that create an instance of this class with the icon index at (0, 0), (1, 0), and so on and so forth. I know that the icons are 18*18, so I started at (0, 0) on the image, and then put the X value up by 18 [(18, 0), (36, 0), blah blah blah blah]. When it displays the effect image, it shows nothing, just an empty black rectangle.

    I don't know what's going on. Where should I put the Y value of these images?  Please help, and thank you in advance.

  4. OK, so I got NBTExplorer to look at the hub.nbt and it said the chest was located at x 2, y 1, and z 3. So I created a BlockPos of pos.getX() + 2, pos.getY() + 1, pos.getZ() + 3 (see above post for the pos variable). Here is my code:

    IBlockState state = world.getBlockState(pos);
    			world.notifyBlockUpdate(pos, state, state, 3);
    			template.addBlocksToWorldChunk(world, pos, settings);
    			BlockPos chestPos = new BlockPos(pos.getX() + 2, pos.getY() + 1, pos.getZ() + 3);
    			TileEntity tileentity = world.getTileEntity(chestPos);
    			
    			if(tileentity == null) {
    				
    				Main.logger.info("There is no chest!!! Run away!!!");
    				return;
    			}
    			
    			if(tileentity instanceof TileEntityChest) {
    				
    				TileEntityChest tileEntityChest = (TileEntityChest) tileentity;
    				tileEntityChest.setLootTable(new ResourceLocation(Reference.MOD_ID + ":hub_chest.json"), new Random(world.getSeed()).nextLong());
    				tileEntityChest.fillWithLoot(null);
    			}

    When I run the game, it says "There is no chest!!! Run away!!!" repeatedly. I don't know what's wrong.

     

    And by the way, I tried running the loop in loop in loop code and it didn't work. I clearly have the loot table correctly named, as you can see in the attached image.

     

    Yes, there is a chest in there. To prove it, I the second screenshot clearly shows a minecraft:chest in there.

     

    Please help, and thank you in advance.

    screenshot.JPG

    screenshot2.JPG

  5. It said null and when I opened the chest it had nothing. It has given me no errors, no anything. I even used a custom loot table generator and it didn't work. Please help!!!

     

    Here's my code:

    public static void generateStructure(World world, BlockPos pos) {
    		
    		MinecraftServer mcServer = world.getMinecraftServer();
    		TemplateManager manager = worldServer.getStructureTemplateManager();
    		ResourceLocation location = new ResourceLocation(Reference.MOD_ID, structureName);
    		Template template = manager.get(mcServer, location);
    		
    		if(template != null) {
    			
    			IBlockState state = world.getBlockState(pos);
    			world.notifyBlockUpdate(pos, state, state, 3);
    			template.addBlocksToWorldChunk(world, pos, settings);
    			for(int x = 0; x <= template.getSize().getX(); x++) {
    				
    				for(int y = 0; y <= template.getSize().getY(); y++) {
    					
    					for(int z = 0; z <= template.getSize().getZ(); z++){
    						
    						BlockPos tmp = new BlockPos(pos.getX() + x, pos.getY() + y, pos.getZ() + z);
    							
    						if(world.getTileEntity(tmp) != null){
    							
    							if(world.getTileEntity(tmp) instanceof TileEntityChest){
    								
    								TileEntityChest chest = (TileEntityChest) world.getTileEntity(tmp);
    								chest.setLootTable(new ResourceLocation(Reference.MOD_ID + ":hub_chest.json"), new Random(chest.getWorld().getSeed()).nextLong());
    								chest.fillWithLoot(null);
    							}
    						}
    					}
    				}
    			}
    		}
    	}

     

  6. So... exactly how would you do this? Would you set worldIn to playerIn.getEntityWorld() and then call setblockState()? Something like this?

    @Override
    	public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
    			EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    		
    		if(!worldIn.isRemote) {
    			
    			if(playerIn.dimension != 2) {
    				
    				Teleport.TeleportToDimension(playerIn, 2, playerIn.posX, playerIn.posY, playerIn.posZ);
    				worldIn = playerIn.getEntityWorld();
    				worldIn.setBlockState(new BlockPos(hitX,  hitY - 1, hitZ), ModBlocks.ICE_PORTAL_BLOCK.getDefaultState());
    			} else if (playerIn.dimension == 2) {
    				
    				Teleport.TeleportToDimension(playerIn, 0, pos.getX(), pos.getY(), pos.getZ());
    				worldIn = playerIn.getEntityWorld();
    				worldIn.setBlockState(new BlockPos(hitX, hitY - 1, hitZ), ModBlocks.ICE_PORTAL_BLOCK.getDefaultState());
    			}
    		}
    		return true;
    	}

     

  7. Hi,

     

    I am trying to make it so that when you take my ice age portal you teleport to that dimension and another ice age portal appears under your feet. But for some reason, it doesn't work. I spawn far from an island with no supports (aka the block that should've been placed). Here is my code:

    @Override
    	public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
    			EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    		
    		if(!worldIn.isRemote) {
    			
    			if(playerIn.dimension != 2) {
    				
    				Teleport.TeleportToDimension(playerIn, 2, playerIn.posX, playerIn.posY, playerIn.posZ);
    				worldIn.setBlockState(new BlockPos(hitX,  hitY - 1, hitZ), ModBlocks.ICE_PORTAL_BLOCK.getDefaultState());
    			} else if (playerIn.dimension == 2) {
    				
    				Teleport.TeleportToDimension(playerIn, 0, pos.getX(), pos.getY(), pos.getZ());
    				worldIn.setBlockState(new BlockPos(hitX, hitY - 1, hitZ), ModBlocks.ICE_PORTAL_BLOCK.getDefaultState());
    			}
    		}
    		return true;
    	}

    So I have two questions:

    1. How do you decide what dimension the block is placed in, in setBlockState?

    2. Why is this not working? I don't see any problem. I even tried to follow the end code for when it places the dragon egg on the top of the bedrock pillar.

     

    Any help would be appreciated, and thank you in advance.

  8. Yeah, I bet you edited the config (or maybe accidentally put a minus sign in there somewhere!). Copy in the config file so we can see it.

     

    EDIT:

    I definitely think you edited the config, either by accident or on purpose. The "height" variable on the default config (at least for me, but it would be crazy if the default config was different for you and me) was set to a number that wasn't out of bounds.

  9. 1 hour ago, nikii said:

        at it.zerono.mods.zerocore.lib.world.WorldGenMinableOres.addOre(WorldGenMinableOres.java:40)

    It looks like the mod it trying to register ores outside of the world limits (y < 0, y > 255) and that is causing the error. (on top it says "invalid Y coordinates")

    I don't know how that is caused, but that is my best guess on why the error was caused.

  10. 3 hours ago, jabelar said:

    Assuming you ran the full gradlew setupDecompWorkspace when you were setting up your workspace, then you should have all the source available as a Referenced Library in your project. So if you go to the Package Explorer pane you can navigate to the referenced libraries and find one (usually the first in the list) there should be one called forgeSrc and you can go into that to find all the net.minecraft and net.minecraftforge packages with code.

     

    That is for generally browsing the code. However, you can also find specific stuff. For example, your code extends WorldProvider. So if you want to see the code for that, you just click somewhere in the word or select it and then right-click and select Open Declaration. That will open up the source for that.

     

    Now the overworld probably extends WorldProvider so to find all the code that extends that, select the word and right-click and select Open Type Hierarchy. That will open up a pane that will show you all the classes derived from it, and also all the methods in it and inherited by it. You can then double-click on one of the derived classes to open up its source.

     

    So specifically for this case I would:

    1) Open up your world provider class

    2) Go to top of the class where you extend WorldProvider, right click on the world "WorldProvider" and select Open Type Hierarchy.

    3) A pane will pop up that shows that there are derived classes and one of them is called WorldProviderSurface. You can guess that that is probably the overrworld. So double-click that in the hierarchy window, and that will open the source.

    4) You'll find that the WorldProviderSurface doesn't override very many methods. You're interested in the celestial angle, which isn't overridden. So you will want to go up the hierarchy. So double-click the WorldProvider class in the hierarchy window.

    5) Scroll through the code, or use Control-F, to find the calculateCelestialAngle() code.

     

    Basically using these techniques of selecting, using Type Hierarchy, you can quickly navigate through the parent and children classes.

     

    One other tip, when you bring up the Type Hierarchy it will also list all the fields and methods in the selected class. However, there is a toggle option (one of the small icons) where you can have it list all inherited methods. If that was on, you also can find the calculateCelestialAngle() method there and immediately see if it has overrides.

    You can also hold down "control" (or "command" on Mac) in order to get the declaration of a function.

  11. WorldProviderSurface has no calculateCelestialAngle. By default, it says in the world provider the code above, and WorldProviderSurvace does not override it, so it is the correct code. (I just found out how to access the whole Minecraft library, so I looked in it till I found WorldProvideSurface.)

     

    So when I wondered whether you had to just delete calculateCelestialAngle, I was right. But I was also right in the way that you had to change something. Weird!

     

  12. I looked in the super implementation code, and it's this:

    int i = (int)(worldTime % 24000L);
            float f = ((float)i + partialTicks) / 24000.0F - 0.25F;
    
            if (f < 0.0F)
            {
                ++f;
            }
    
            if (f > 1.0F)
            {
                --f;
            }
    
            float f1 = 1.0F - (float)((Math.cos((double)f * Math.PI) + 1.0D) / 2.0D);
            f = f + (f1 - f) / 3.0F;
            return f;

    Is this the correct code? Please respond quickly.

×
×
  • Create New...

Important Information

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