SlimeVoid / LittleBlocks-FML

LittleBlocks for FML
http://www.slimevoid.net/LittleBlocks
GNU Lesser General Public License v3.0
18 stars 13 forks source link

Added ladder handling #44

Closed Tarig0 closed 11 years ago

UncleMion commented 11 years ago

I think I have a simpler and cleaner way to code that isLadder() method. What do I need to do? Do I make another fork from yours and then commit that?

Tarig0 commented 11 years ago

just go into my fork and fork it from there I think

https://github.com/Tarig0/LittleBlocks-FML

UncleMion commented 11 years ago

Shoot, having trouble getting it set up, and I don't have time to wrestle with github right now, so I'll just paste here some completely untested code that you can try:

    @Override
    public boolean isLadder(World world, int x, int y, int z,EntityLiving entity)
    {
        TileEntity tile2 = world.getBlockTileEntity(x, y, z);
        if (tile2 != null && (tile2 instanceof TileEntityLittleChunk))
        {
            TileEntityLittleChunk tile = (TileEntityLittleChunk) tile2;
            int i = MathHelper.floor_double(entity.posX * (double)tile.size);
            int j = MathHelper.floor_double(entity.boundingBox.minY * (double)tile.size);
            int k = MathHelper.floor_double(entity.posZ * (double)tile.size);
            int blockid = tile.getBlockID(i % tile.size, j % tile.size, k % tile.size);
            return Block.blocksList[blockid] != null && Block.blocksList[blockid].isLadder((World) tile.getLittleWorld(), i, j, k, entity);
        }
        return false;
    }

It's basically the same way vanilla Minecraft handles the ladder, by just checking the one lil'block. Only players around tiny size and mobs of very small width could use them.

ali4z commented 11 years ago

No casting safety? How exotic! :P

EDIT: <3

Tarig0 commented 11 years ago

That would be a much cleaner way to do things, unfortunately I want this to work for players that don't have Gulliver installed. That's the only reason why I scan the horizontal square around the entity for the ladder. What we could do is add in a if statement to check if entity width <= 1/7 or 1/8 meter and use this bit of code there

btw if you use javaclose it with another you can format your code ` is on the ~ key

Tarig0 commented 11 years ago

ah figured out why you can't fork my repo @UncleMion you need to delete the fork you already created since you can't have two repos with the same name

UncleMion commented 11 years ago

Ah, I see; I had the impression that you only wanted to allow tiny players to use the ladders. My bad.

I've got code in my EntityLiving.isOnLadder() that does a similarish check on surrounding blocks. I'll use that to do a different isLadder() after I fix the fork.

By the way, java wasn't formatting my code correctly, so I just put it back to the that I had before. Is ``` supposed to do syntax checking when you put "java" in front? Does it not work on blocks of code?

EDIT: grr I need to figure out this markdown syntax, wish I had a preview button when editing a comment...

Tarig0 commented 11 years ago

sorry put java on the inside of the first ```

you can escape ` with the \ character

https://help.github.com/articles/github-flavored-markdown

UncleMion commented 11 years ago

Thanks :)

Tarig0 commented 11 years ago

oo to clarify my intent I want to allow regular players to use LB ladders only if Gulliver is not installed if it is I want them to follow your rules, I figured half size was small enough since giants can use regular ladders some how

Tarig0 commented 11 years ago

there we go much better handling, now to check with guliver

Tarig0 commented 11 years ago

hmm can't figure out why but with Gulliver I can only climb things on the lowest X (WEST) side of a little chunk. Works fine without Gulliver. Think it's in your ballpark mion.

Eurymachus commented 11 years ago

Will test this tonight

Tarig0 commented 11 years ago

how'd the testing go?

Tarig0 commented 11 years ago

Nothing from testing?

Eurymachus commented 11 years ago

Hi Guys, Looks like something is broken with the calculations. Just testing in 1.6.2 just a straight pull over and the calculation doesn't seem to be working as intended.

Tarig, are you able to pull the 1.6.2 branch and do some testing yourself please.

I'll commit the code that I've pulled over for now.

Eurymachus commented 11 years ago

Ill add this as an issue instead.

Eurymachus commented 11 years ago

https://github.com/SlimeVoid/LittleBlocks-FML/issues/23

Eurymachus commented 11 years ago

Resolved in ff612c0c4643b4fc09f500cd7d9d270d0635781c