Jump to content

Recommended Posts

Posted

I think this is a bug with eclipse, it's done this to me a few times and i can't remember there ever being much of a reason. To sound cliched "have you tried turning it off and on again?" :D

Posted

I tried, but when I create the constructor (either as public or protected)

protected BlockMyLeaves(int par1) {
	super(par1);
}

It tells me to add a BlockMyLeaves(int) constructor, and when i click on it, it creates the same one -.-

Make it public rather than protected.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Posted

Thanks ! It's working, cuz tree leaves now :

- are Instabreakable

- don't loot sticks

- are non-transparent

 

Leaves still disappear when tree is broken, and have light opacity to 1

 

Need to fix this, and more and more thanks to you !

\o_ \o/ _o/

||    ||    ||

/ \  / \  / \

Posted

Thanks ! It's working, cuz tree leaves now :

- are Instabreakable

- don't loot sticks

- are non-transparent

 

Leaves still disappear when tree is broken, and have light opacity to 1

 

Need to fix this, and more and more thanks to you !

\o_ \o/ _o/

||    ||    ||

/ \  / \  / \

 

i'm confused is that good or bad?

 

also... why the dancing stick men?

Posted

It's good, because this means we (you) achieved to replace Leaves by MyLeaves (i checked, and even in the creative inventory, with the leaves ID, it's 4 non-named blocks with leaves textures)

 

I need to give MyLeaves the characteristics I want, but it may be easier from now :)

EDIT : I don't know how to do it --'

          Aren't BlockLeaves methods supposed to be usable with BlockMyLeaves ?

 

Posted

haha, ok. Look through the wiki a bit and see what you can figure out, Try to do as much as you can without help as it's a better way of learning and you'll start to figure out how to solve these things in the future. If you get completely stuck post it or feel free DM me with the problem and i'll do my best to get back to you, and point you in the right direction. There is also quite a lot of good stuff on youtube if you do a quick search.

 

Posted

          Aren't BlockLeaves methods supposed to be usable with BlockMyLeaves ?

 

yes. They should be if you extended it. The properties of the leaves however you will need to set using .setHardness and various other methods. Look here if you're not sure how to set the properties, it's a touch out of date, but all that's really changed is textures and you don't need to do anything about that.

Posted

In the BlockMyLeaves class, I use the constructor

public BlockMyLeaves(int par1) {
	super(par1);
        setHardness(0.2F);
        setLightOpacity(1);
        setStepSound(soundGrassFootstep);
        setUnlocalizedName("leaves");
}

and super(...) is BlockLeaves(...) from vanilla

protected BlockLeaves(int par1)
    {
        super(par1, Material.leaves, false);
        this.setTickRandomly(true);
        this.setCreativeTab(CreativeTabs.tabDecorations);
    }

 

I don't understand why MyLeaves doesn't have the Material.leaves properties, while it is created as a block with leaves material :/

Posted

In the BlockMyLeaves class, I use the constructor

public BlockMyLeaves(int par1) {
	super(par1);
        setHardness(0.2F);
        setLightOpacity(1);
        setStepSound(soundGrassFootstep);
        setUnlocalizedName("leaves");
}

and super(...) is BlockLeaves(...) from vanilla

protected BlockLeaves(int par1)
    {
        super(par1, Material.leaves, false);
        this.setTickRandomly(true);
        this.setCreativeTab(CreativeTabs.tabDecorations);
    }

 

I don't understand why MyLeaves doesn't have the Material.leaves properties, while it is created as a block with leaves material :/

Material.leaves is linked to a few scattered properties; the "material" thing isn't very well organized. What properties is your block missing?

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Posted

from memory I think it's these methods, Kinda set it up so my code does most of this automatically now, so i could be missing something.

@Override
public boolean renderAsNormalBlock()
{
	return false;
}

@Override
public boolean isOpaqueCube()
{
	return false;
}

 

to drop items I think something like this:

    public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune)
    {
        ArrayList<ItemStack> ret = new ArrayList<ItemStack>();

        int count = quantityDropped(metadata, fortune, world.rand);
        for(int i = 0; i < count; i++)
        {
            int id = idDropped(metadata, world.rand, fortune);
            if (id > 0)
            {
                ret.add(new ItemStack(id, 1, damageDropped(metadata)));
            }
        }

        ret.add(new ItemStack(Item.stick));
        return ret;
    }

Posted

Leaves are now rendered as glass, so it won't make us able to see caves, but connected leaves will only render their front face

And it doesn't drop sticks ;S

Posted

Leaves are now rendered as glass, so it won't make us able to see caves, but connected leaves will only render their front face

And it doesn't drop sticks ;S

You might have to redefine quantityDropped() as well; if it returns 0 every time you won't get anything.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Posted

I only redefined public void dropBlockAsItemWithChance(...)

public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
    {
        if (!par1World.isRemote)
        {
            int j1 = 20;

            if ((par5 & 3) == 3)
            {
                j1 = 40;
            }

            if (par7 > 0)
            {
                j1 -= 2 << par7;

                if (j1 < 10)
                {
                    j1 = 10;
                }
            }

            if (par1World.rand.nextInt(j1) == 0)
            {
                int k1 = this.idDropped(par5, par1World.rand, par7);
                this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(k1, 1, this.damageDropped(par5)));
            }
            
            j1 = 20;

            if ((par5 & 3) == 3)
            {
                j1 = 40;
            }

            if (par7 > 0)
            {
                j1 -= 2 << par7;

                if (j1 < 10)
                {
                    j1 = 10;
                }
            }
            
            if (par1World.rand.nextInt(j1) == 0)
            {
                int k1 = Item.stick.itemID;
                this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(k1, 1, this.damageDropped(par5)));
            }

            j1 = 200;

            if (par7 > 0)
            {
                j1 -= 10 << par7;

                if (j1 < 40)
                {
                    j1 = 40;
                }
            }

            if ((par5 & 3) == 0 && par1World.rand.nextInt(j1) == 0)
            {
                this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(Item.appleRed, 1, 0));
            }
        }
    }
}

 

And it works ! Sticks drop of leaves as often as saplings !

Only 2 problems left : Add recipe for spruce, birch and jungle saplings, and change transparency of leaves to make it appear correctly

EDIT : The first one was simple, i looked on sandstone recipes to know how to add :1, :2, :3 to the block ID :)

EDIT 2 : Transparency problem screenshot :

http://puu.sh/3bIOI

Posted

BlockMyLeaves is already extending BlockLeaves, which extends BlockLeavesBase

 

I tried with renderAsNormalBlock(), isOpaqueCube(), setGraphicsLevel(), shouldSideBeRendered() and isLeaves(), and all in same time, but none of them makes it work properly. Fast graphics also render as fancy.

Posted

It works ! I didn't tried that, i'm... kinda... ~("°A°)~

There's still 1 problem left : Fast graphics use fancy texture, and it render exactly like with fancy graphics

Posted

It works ! I didn't tried that, i'm... kinda... ~("°A°)~

There's still 1 problem left : Fast graphics use fancy texture, and it render exactly like with fancy graphics

You'll need a graphicsLevel variable, set up as in BlockLeaves and BlockLeavesBase.

if graphicsLevel = "fancy":
    return True
else:
    return super(self, blah).shouldSideBeRendered()

You'll also want to override isOpaqueCube:

    public boolean isOpaqueCube(){
        return !this.graphicsLevel;
    }

And you'll need two sets of icons, one opaque and one transparent. Look at BlockLeaves.iconArray for how it's done.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Posted

It works ! I didn't tried that, i'm... kinda... ~("°A°)~

There's still 1 problem left : Fast graphics use fancy texture, and it render exactly like with fancy graphics

You'll need a graphicsLevel variable, set up as in BlockLeaves and BlockLeavesBase.

if graphicsLevel = "fancy":
    return True
else:
    return super(self, blah).shouldSideBeRendered()

 

Look at the BlockLeaves class, you can adapt the code where graphicsLevel is used (it's a boolean).

You don't need to declare a new variable in your block class, just use the Block.leaves.graphicsLevel reference, since the variable is public.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

It works ! I didn't tried that, i'm... kinda... ~("°A°)~

There's still 1 problem left : Fast graphics use fancy texture, and it render exactly like with fancy graphics

You'll need a graphicsLevel variable, set up as in BlockLeaves and BlockLeavesBase.

if graphicsLevel = "fancy":
    return True
else:
    return super(self, blah).shouldSideBeRendered()

 

Look at the BlockLeaves class, you can adapt the code where graphicsLevel is used (it's a boolean).

You don't need to declare a new variable in your block class, just use the Block.leaves.graphicsLevel reference, since the variable is public.

Good point. I guess I didn't want to bother doing more research than necessary :)

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi, this is my second post with the same content as no one answered this and it's been a long time since I made the last post, I want to make a client-only mod, everything is ok, but when I use shaders, none of the textures rendered in RenderLevelStageEvent nor the crow entity model are rendered, I want them to be visible, because it's a horror themed mod I've already tried it with different shaders, but it didn't work with any of them and I really want to add support for shaders Here is how i render the crow model in the CrowEntityRenderer<CrowEntity>, by the time i use this method, i know is not the right method but i don't think this is the cause of the problem, the renderType i'm using is entityCutout @Override public void render(CrowEntity p_entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { super.render(p_entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); ClientEventHandler.getClient().crow.renderToBuffer(poseStack, bufferSource.getBuffer(ClientEventHandler.getClient().crow .renderType(TEXTURE)), packedLight, OverlayTexture.NO_OVERLAY, Utils.rgb(255, 255, 255)); } Here renderLevelStage @Override public void renderWorld(RenderLevelStageEvent e) { horrorEvents.draw(e); } Here is how i render every event public void draw(RenderLevelStageEvent e) { for (HorrorEvent event : currentHorrorEvents) { event.tick(e.getPartialTick()); event.draw(e); } } Here is how i render the crow model on the event @Override public void draw(RenderLevelStageEvent e) { if(e.getStage() == RenderLevelStageEvent.Stage.AFTER_ENTITIES) { float arcProgress = getArcProgress(0.25f); int alpha = (int) Mth.lerp(arcProgress, 0, 255); int packedLight = LevelRenderer.getLightColor(Minecraft.getInstance().level, blockPos); VertexConsumer builder = ClientEventHandler.bufferSource.getBuffer(crow); Crow<CreepyBirdHorrorEvent> model = ClientEventHandler .getClient().crow; model.setupAnim(this); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, packedLight, OverlayTexture.NO_OVERLAY, alpha); builder = ClientEventHandler.bufferSource.getBuffer(eyes); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, 15728880, OverlayTexture.NO_OVERLAY, alpha); } } How i render the model public static void renderModelInWorld(Model model, Vector3f pos, Vector3f offset, Camera camera, PoseStack matrix, VertexConsumer builder, int light, int overlay, int alpha) { matrix.pushPose(); Vec3 cameraPos = camera.getPosition(); double finalX = pos.x - cameraPos.x + offset.x; double finalY = pos.y - cameraPos.y + offset.y; double finalZ = pos.z - cameraPos.z + offset.z; matrix.pushPose(); matrix.translate(finalX, finalY, finalZ); matrix.mulPose(Axis.XP.rotationDegrees(180f)); model.renderToBuffer(matrix, builder, light, overlay, Utils .rgba(255, 255, 255, alpha)); matrix.popPose(); matrix.popPose(); } Thanks in advance
    • Same issue - I have no idea
    • I am trying to develop a modpack for me and my friends to use on our server. Does anyone know how to develop a modpack for a server or could they help take a look at my modpack to potentially help at all?
    • un server de armas realista.  
    • removed both, nope https://pastebin.com/kgtwq9us
  • Topics

×
×
  • Create New...

Important Information

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