Jump to content

Recommended Posts

Posted

I am trying to find out how to get the permitted datavalues from TileEntity classes before they are drawn (rendered or instantiated). Stairs specifically must rotate in a fill statement before placement.

 

I am pretty sure getValidRotations isn't what I want here.

 

My use case is to rotate the objects in a command set (my mod supports multi-line command sets as components along North,South,East,West) before it's executed. If the commands has a fill or set block of objects like stairs or wood, I need to rotate the data values. My problem is that datavalues aren't consistent for rotation for all types of blocks. That is- the rotating of minecraft:stone_stairs or yourmod:stairs from a south orientation is different from the values in rotating wood which is different from wall. The mod's command ExecuteFile can have any command including itself.

 

Walls have datavalues of 2-5 - Rotating a south (value) wall to the right in the fill command changes the datavalue from 2 to 4.

 

Stairs have 0-15 - Rotating from south to west changes the value from 0 to 4.

 

Nothing consistent.

 

In my use case, the files can also invoke files. That means rotations in the mod must also allow cascading with other components.  Teleports, blockdata, etc all must rotate and the rotation must cascade.

 

I need a scheme for getting block rotation changes data values, BEFORE I run commands.

 

Hoping this is built in and I missed it. Otherwise I code and config the solution. but it's preferable (vastly preferred) to get some of all the block types rotations (classes) from vanilla and mods dynamically.

Posted

Hi

 

Bad news, I'm afraid... If you want that robustly, I suggest you migrate to 1.8 which uses BlockStates and facing to let you do this properly.

 

There is an inbuilt forge method in 1.7.10 (Block.rotateBlock()) but it's only good for rotating in place, it's useless for rotating metadata values.

 

I needed to do this for a mod of mine and in the end I copied the helper class from WorldEdit (on GitHub) which manually coded the values for every single block.

 

-TGG

Posted

Sir, I am using 1.8 only, but it doesn't have what I need either.

 

Thank you for the timely reply

 

Then for robust configurability, It's information I need to read from the configurable file with types (Stair_type), and specific names "minecraft:stone_stairs" or Yourmod:your_stairs". 

 

--------------------------------------------------------------

I'll post the code to read the configuration file when I write it with a helper function returning the new datavalue for rotation by forgedirection. --- I'll also create a command or api to add to the file so it's accessible for users, modders in the game.

----------------------------------------------------------------------------------------------------------------------------------

 

After the /ExecuteFile is sufficient, The next step is an /ExecuteOnEvent command for terrain generation events with a randomness percentage. My final use case is to give two simple commands that allow the average map maker or redstoner to have custom generation of cities, structures, and other things from "simple - easy to program" command files.

 

 

Posted

Ghost, I looked at https://github.com/sk89q/WorldEdit/blob/master/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockData.java. I'll probably extend the code differently and hook it to a generic type.

 

It's close, but it's not configurable for any other custom mod's blockdata.

 

I realized on reading it, I would need to allow modders with custom commands to add to the command types of rotation for my mod. No reason to do the same hard coding as blockdata.java.  BlockId's aren't stable across mods, so more thinking is required.

 

---------------------------------------------------------------------

I'm not clear on how mods should communicate capabilities to other mods in forge. 

 

I'm using the following for now.

 

import net.minecraft.block.*;

import net.minecraft.init.Blocks;

// import net.minecraft.init.Blocks;  Implement later

public class BlockRotationExtended {

 

 

public BlockRotationExtended() {

// TODO Auto-generated constructor stub

}

/*

* WorldEdit, a Minecraft world manipulation toolkit

* Copyright © sk89q <http://www.sk89q.com>

* Copyright © WorldEdit team and contributors

*

* This program is free software: you can redistribute it and/or modify it

* under the terms of the GNU Lesser General Public License as published by the

* Free Software Foundation, either version 3 of the License, or

* (at your option) any later version.

*

* This program is distributed in the hope that it will be useful, but WITHOUT

* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or

* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License

* for more details.

*

* You should have received a copy of the GNU Lesser General Public License

* along with this program. If not, see <http://www.gnu.org/licenses/>.

*/

 

// package com.sk89q.worldedit.blocks;

 

// import com.sk89q.worldedit.CuboidClipboard.FlipDirection;

// import net.minecraft.block.*;

 

/**

* Block data related classes.

*/

 

 

    /**

    * Rotate a block's data value 90 degrees (north->east->south->west->north);

    *

    * @param type the type ID of the bock

    * @param data the data ID of the block

    * @return the new data value

    */

public static int rotate90byForgeBlocks(Blocks forgeblocktype, int datavalue) {

 

// Look up

System.out.println("Forge Blocks instanceof class not yet supported");

 

return 0;

 

 

}

 

public static int rotate90byname(String blockname, int datavalue) {

if (blockname.toUpperCase().trim().matches("MINECRAFT:")) {

return rotate90(Block.getIdFromBlock(Block.getBlockFromName(blockname)),datavalue);

}

else {

// Look up

System.out.println("Non Vanilla blocks not yet supported");

}

return 0;

 

}

 

public static int flipbyname(String blockname, int datavalue, FlipDirection direction) {

if (blockname.toUpperCase().trim().matches("MINECRAFT:")) {

return flip((Block.getIdFromBlock(Block.getBlockFromName(blockname))),datavalue,direction);

}

else {

// TODO : Look up

System.out.println("Non Vanilla blocks not yet supported");

}

return 0;

 

}

 

public static int flipbyname(String blockname, int datavalue) {

if (blockname.toUpperCase().trim().matches("MINECRAFT:")) {

return flip((Block.getIdFromBlock(Block.getBlockFromName(blockname))),datavalue);

}

else {

// Look up

System.out.println("Non Vanilla blocks not yet supported");

}

return 0;

 

}

    public static int rotate90(int type, int data) {

    // Blocks.

        switch (type) {

       

        case BlockID.TORCH:

        case BlockID.REDSTONE_TORCH_OFF:

        case BlockID.REDSTONE_TORCH_ON:

            switch (data) {

            case 1: return 3;

            case 2: return 4;

            case 3: return 2;

            case 4: return 1;

            }

            break;

 

        case BlockID.MINECART_TRACKS:

            switch (data) {

            case 6: return 7;

            case 7: return 8;

            case 8: return 9;

            case 9: return 6;

            }

            /* FALL-THROUGH */

 

        case BlockID.POWERED_RAIL:

        case BlockID.DETECTOR_RAIL:

        case BlockID.ACTIVATOR_RAIL:

            switch (data & 0x7) {

            case 0: return 1 | (data & ~0x7);

            case 1: return 0 | (data & ~0x7);

            case 2: return 5 | (data & ~0x7);

            case 3: return 4 | (data & ~0x7);

            case 4: return 2 | (data & ~0x7);

            case 5: return 3 | (data & ~0x7);

            }

            break;

 

        case BlockID.OAK_WOOD_STAIRS:

        case BlockID.COBBLESTONE_STAIRS:

        case BlockID.BRICK_STAIRS:

        case BlockID.STONE_BRICK_STAIRS:

        case BlockID.NETHER_BRICK_STAIRS:

        case BlockID.SANDSTONE_STAIRS:

        case BlockID.SPRUCE_WOOD_STAIRS:

        case BlockID.BIRCH_WOOD_STAIRS:

        case BlockID.JUNGLE_WOOD_STAIRS:

        case BlockID.QUARTZ_STAIRS:

        case BlockID.ACACIA_STAIRS:

        case BlockID.DARK_OAK_STAIRS:

            switch (data) {

            case 0: return 2;

            case 1: return 3;

            case 2: return 1;

            case 3: return 0;

            case 4: return 6;

            case 5: return 7;

            case 6: return 5;

            case 7: return 4;

            }

            break;

 

        case BlockID.STONE_BUTTON:

        case BlockID.WOODEN_BUTTON: {

            int thrown = data & 0x8;

            switch (data & ~0x8) {

            case 1: return 3 | thrown;

            case 2: return 4 | thrown;

            case 3: return 2 | thrown;

            case 4: return 1 | thrown;

            // 0 and 5 are vertical

            }

            break;

        }

 

        case BlockID.LEVER: {

            int thrown = data & 0x8;

            switch (data & ~0x8) {

            case 1: return 3 | thrown;

            case 2: return 4 | thrown;

            case 3: return 2 | thrown;

            case 4: return 1 | thrown;

            case 5: return 6 | thrown;

            case 6: return 5 | thrown;

            case 7: return 0 | thrown;

            case 0: return 7 | thrown;

            }

            break;

        }

 

        case BlockID.WOODEN_DOOR:

        case BlockID.IRON_DOOR:

            if ((data & 0x8) != 0) {

                // door top halves contain no orientation information

                break;

            }

 

            /* FALL-THROUGH */

 

        case BlockID.COCOA_PLANT:

        case BlockID.TRIPWIRE_HOOK: {

            int extra = data & ~0x3;

            int withoutFlags = data & 0x3;

            switch (withoutFlags) {

            case 0: return 1 | extra;

            case 1: return 2 | extra;

            case 2: return 3 | extra;

            case 3: return 0 | extra;

            }

            break;

        }

        case BlockID.SIGN_POST:

            return (data + 4) % 16;

 

        case BlockID.LADDER:

        case BlockID.WALL_SIGN:

        case BlockID.CHEST:

        case BlockID.FURNACE:

        case BlockID.BURNING_FURNACE:

        case BlockID.ENDER_CHEST:

        case BlockID.TRAPPED_CHEST:

        case BlockID.HOPPER: {

            int extra = data & 0x8;

            int withoutFlags = data & ~0x8;

            switch (withoutFlags) {

            case 2: return 5 | extra;

            case 3: return 4 | extra;

            case 4: return 2 | extra;

            case 5: return 3 | extra;

            }

            break;

        }

        case BlockID.DISPENSER:

        case BlockID.DROPPER:

            int dispPower = data & 0x8;

            switch (data & ~0x8) {

            case 2: return 5 | dispPower;

            case 3: return 4 | dispPower;

            case 4: return 2 | dispPower;

            case 5: return 3 | dispPower;

            }

            break;

 

        case BlockID.PUMPKIN:

        case BlockID.JACKOLANTERN:

            switch (data) {

            case 0: return 1;

            case 1: return 2;

            case 2: return 3;

            case 3: return 0;

            }

            break;

 

        case BlockID.HAY_BLOCK:

        case BlockID.LOG:

        case BlockID.LOG2:

            if (data >= 4 && data <= 11) data ^= 0xc;

            break;

 

        case BlockID.COMPARATOR_OFF:

        case BlockID.COMPARATOR_ON:

        case BlockID.REDSTONE_REPEATER_OFF:

        case BlockID.REDSTONE_REPEATER_ON:

            int dir = data & 0x03;

            int delay = data - dir;

            switch (dir) {

            case 0: return 1 | delay;

            case 1: return 2 | delay;

            case 2: return 3 | delay;

            case 3: return 0 | delay;

            }

            break;

 

        case BlockID.TRAP_DOOR:

            int withoutOrientation = data & ~0x3;

            int orientation = data & 0x3;

            switch (orientation) {

            case 0: return 3 | withoutOrientation;

            case 1: return 2 | withoutOrientation;

            case 2: return 0 | withoutOrientation;

            case 3: return 1 | withoutOrientation;

            }

            break;

 

        case BlockID.PISTON_BASE:

        case BlockID.PISTON_STICKY_BASE:

        case BlockID.PISTON_EXTENSION:

            final int rest = data & ~0x7;

            switch (data & 0x7) {

            case 2: return 5 | rest;

            case 3: return 4 | rest;

            case 4: return 2 | rest;

            case 5: return 3 | rest;

            }

            break;

 

        case BlockID.BROWN_MUSHROOM_CAP:

        case BlockID.RED_MUSHROOM_CAP:

            if (data >= 10) return data;

            return (data * 3) % 10;

 

        case BlockID.VINE:

            return ((data << 1) | (data >> 3)) & 0xf;

 

        case BlockID.FENCE_GATE:

            return ((data + 1) & 0x3) | (data & ~0x3);

 

        case BlockID.ANVIL:

            return data ^ 0x1;

 

        case BlockID.BED:

            return data & ~0x3 | (data + 1) & 0x3;

 

        case BlockID.HEAD:

            switch (data) {

                case 2: return 5;

                case 3: return 4;

                case 4: return 2;

                case 5: return 3;

            }

        }

 

        return data;

    }

 

    /**

    * Rotate a block's data value -90 degrees (north<-east<-south<-west<-north);

    *

    * @param type the type ID of the bock

    * @param data the data ID of the block

    * @return the new data value

    */

    public static int rotate90Reverse(int type, int data) {

        // case ([0-9]+): return ([0-9]+) -> case \2: return \1

 

        switch (type) {

        case BlockID.TORCH:

        case BlockID.REDSTONE_TORCH_OFF:

        case BlockID.REDSTONE_TORCH_ON:

            switch (data) {

            case 3: return 1;

            case 4: return 2;

            case 2: return 3;

            case 1: return 4;

            }

            break;

 

        case BlockID.MINECART_TRACKS:

            switch (data) {

            case 7: return 6;

            case 8: return 7;

            case 9: return 8;

            case 6: return 9;

            }

            /* FALL-THROUGH */

 

        case BlockID.POWERED_RAIL:

        case BlockID.DETECTOR_RAIL:

        case BlockID.ACTIVATOR_RAIL:

            int power = data & ~0x7;

            switch (data & 0x7) {

            case 1: return 0 | power;

            case 0: return 1 | power;

            case 5: return 2 | power;

            case 4: return 3 | power;

            case 2: return 4 | power;

            case 3: return 5 | power;

            }

            break;

 

        case BlockID.OAK_WOOD_STAIRS:

        case BlockID.COBBLESTONE_STAIRS:

        case BlockID.BRICK_STAIRS:

        case BlockID.STONE_BRICK_STAIRS:

        case BlockID.NETHER_BRICK_STAIRS:

        case BlockID.SANDSTONE_STAIRS:

        case BlockID.SPRUCE_WOOD_STAIRS:

        case BlockID.BIRCH_WOOD_STAIRS:

        case BlockID.JUNGLE_WOOD_STAIRS:

        case BlockID.QUARTZ_STAIRS:

        case BlockID.ACACIA_STAIRS:

        case BlockID.DARK_OAK_STAIRS:

            switch (data) {

            case 2: return 0;

            case 3: return 1;

            case 1: return 2;

            case 0: return 3;

            case 6: return 4;

            case 7: return 5;

            case 5: return 6;

            case 4: return 7;

            }

            break;

 

        case BlockID.STONE_BUTTON:

        case BlockID.WOODEN_BUTTON: {

            int thrown = data & 0x8;

            switch (data & ~0x8) {

            case 3: return 1 | thrown;

            case 4: return 2 | thrown;

            case 2: return 3 | thrown;

            case 1: return 4 | thrown;

            // 0 and 5 are vertical

            }

            break;

        }

 

        case BlockID.LEVER: {

            int thrown = data & 0x8;

            switch (data & ~0x8) {

            case 3: return 1 | thrown;

            case 4: return 2 | thrown;

            case 2: return 3 | thrown;

            case 1: return 4 | thrown;

            case 6: return 5 | thrown;

            case 5: return 6 | thrown;

            case 0: return 7 | thrown;

            case 7: return 0 | thrown;

            }

            break;

        }

 

        case BlockID.WOODEN_DOOR:

        case BlockID.IRON_DOOR:

            if ((data & 0x8) != 0) {

                // door top halves contain no orientation information

                break;

            }

 

            /* FALL-THROUGH */

 

        case BlockID.COCOA_PLANT:

        case BlockID.TRIPWIRE_HOOK: {

            int extra = data & ~0x3;

            int withoutFlags = data & 0x3;

            switch (withoutFlags) {

            case 1: return 0 | extra;

            case 2: return 1 | extra;

            case 3: return 2 | extra;

            case 0: return 3 | extra;

            }

            break;

        }

        case BlockID.SIGN_POST:

            return (data + 12) % 16;

 

        case BlockID.LADDER:

        case BlockID.WALL_SIGN:

        case BlockID.CHEST:

        case BlockID.FURNACE:

        case BlockID.BURNING_FURNACE:

        case BlockID.ENDER_CHEST:

        case BlockID.TRAPPED_CHEST:

        case BlockID.HOPPER: {

            int extra = data & 0x8;

            int withoutFlags = data & ~0x8;

            switch (withoutFlags) {

                case 5: return 2 | extra;

                case 4: return 3 | extra;

                case 2: return 4 | extra;

                case 3: return 5 | extra;

            }

            break;

        }

        case BlockID.DISPENSER:

        case BlockID.DROPPER:

            int dispPower = data & 0x8;

            switch (data & ~0x8) {

            case 5: return 2 | dispPower;

            case 4: return 3 | dispPower;

            case 2: return 4 | dispPower;

            case 3: return 5 | dispPower;

            }

            break;

        case BlockID.PUMPKIN:

        case BlockID.JACKOLANTERN:

            switch (data) {

            case 1: return 0;

            case 2: return 1;

            case 3: return 2;

            case 0: return 3;

            }

            break;

 

        case BlockID.HAY_BLOCK:

        case BlockID.LOG:

        case BlockID.LOG2:

            if (data >= 4 && data <= 11) data ^= 0xc;

            break;

 

        case BlockID.COMPARATOR_OFF:

        case BlockID.COMPARATOR_ON:

        case BlockID.REDSTONE_REPEATER_OFF:

        case BlockID.REDSTONE_REPEATER_ON:

            int dir = data & 0x03;

            int delay = data - dir;

            switch (dir) {

            case 1: return 0 | delay;

            case 2: return 1 | delay;

            case 3: return 2 | delay;

            case 0: return 3 | delay;

            }

            break;

 

        case BlockID.TRAP_DOOR:

            int withoutOrientation = data & ~0x3;

            int orientation = data & 0x3;

            switch (orientation) {

            case 3: return 0 | withoutOrientation;

            case 2: return 1 | withoutOrientation;

            case 0: return 2 | withoutOrientation;

            case 1: return 3 | withoutOrientation;

            }

 

        case BlockID.PISTON_BASE:

        case BlockID.PISTON_STICKY_BASE:

        case BlockID.PISTON_EXTENSION:

            final int rest = data & ~0x7;

            switch (data & 0x7) {

            case 5: return 2 | rest;

            case 4: return 3 | rest;

            case 2: return 4 | rest;

            case 3: return 5 | rest;

            }

            break;

 

        case BlockID.BROWN_MUSHROOM_CAP:

        case BlockID.RED_MUSHROOM_CAP:

            if (data >= 10) return data;

            return (data * 7) % 10;

 

        case BlockID.VINE:

            return ((data >> 1) | (data << 3)) & 0xf;

 

        case BlockID.FENCE_GATE:

            return ((data + 3) & 0x3) | (data & ~0x3);

 

        case BlockID.ANVIL:

            return data ^ 0x1;

 

        case BlockID.BED:

            return data & ~0x3 | (data - 1) & 0x3;

 

        case BlockID.HEAD:

            switch (data) {

                case 2: return 4;

                case 3: return 5;

                case 4: return 3;

                case 5: return 2;

            }

        }

 

        return data;

    }

 

    /**

    * Flip a block's data value.

    *

    * @param type the type ID of the bock

    * @param data the data ID of the block

    * @return the new data value

    */

    public static int flip(int type, int data) {

        return rotate90(type, rotate90(type, data));

    }

 

    /**

    * Flip a block's data value.

    *

    * @param type the type ID of the bock

    * @param data the data ID of the block

    * @param direction the direction to flip

    * @return the new data value

    */

    public static int flip(int type, int data, FlipDirection direction) {

        int flipX = 0;

        int flipY = 0;

        int flipZ = 0;

       

       

 

        switch (direction) {

        case NORTH_SOUTH:

            flipZ = 1;

            break;

 

        case WEST_EAST:

            flipX = 1;

            break;

 

        case UP_DOWN:

            flipY = 1;

            break;

        }

 

        switch (type) {

        case BlockID.TORCH:

        case BlockID.REDSTONE_TORCH_OFF:

        case BlockID.REDSTONE_TORCH_ON:

            if (data < 1 || data > 4) break;

            switch (data) {

            case 1: return data + flipX;

            case 2: return data - flipX;

            case 3: return data + flipZ;

            case 4: return data - flipZ;

            }

            break;

 

        case BlockID.STONE_BUTTON:

        case BlockID.WOODEN_BUTTON: {

            switch (data & ~0x8) {

            case 1: return data + flipX;

            case 2: return data - flipX;

            case 3: return data + flipZ;

            case 4: return data - flipZ;

            case 0:

            case 5:

                return data ^ (flipY * 5);

            }

            break;

        }

 

        case BlockID.LEVER:

            switch (data & ~0x8) {

            case 1: return data + flipX;

            case 2: return data - flipX;

            case 3: return data + flipZ;

            case 4: return data - flipZ;

            case 5:

            case 7:

                return data ^ flipY << 1;

            case 6:

            case 0:

                return data ^ flipY * 6;

            }

            break;

 

        case BlockID.MINECART_TRACKS:

            switch (data) {

            case 6: return data + flipX + flipZ * 3;

            case 7: return data - flipX + flipZ;

            case 8: return data + flipX - flipZ;

            case 9: return data - flipX - flipZ * 3;

            }

            /* FALL-THROUGH */

 

        case BlockID.POWERED_RAIL:

        case BlockID.DETECTOR_RAIL:

        case BlockID.ACTIVATOR_RAIL:

            switch (data & 0x7) {

            case 0:

            case 1:

                return data;

            case 2:

            case 3:

                return data ^ flipX;

            case 4:

            case 5:

                return data ^ flipZ;

            }

            break;

 

        case BlockID.STEP:

        case BlockID.WOODEN_STEP:

            return data ^ (flipY << 3);

 

        case BlockID.OAK_WOOD_STAIRS:

        case BlockID.COBBLESTONE_STAIRS:

        case BlockID.BRICK_STAIRS:

        case BlockID.STONE_BRICK_STAIRS:

        case BlockID.NETHER_BRICK_STAIRS:

        case BlockID.SANDSTONE_STAIRS:

        case BlockID.SPRUCE_WOOD_STAIRS:

        case BlockID.BIRCH_WOOD_STAIRS:

        case BlockID.JUNGLE_WOOD_STAIRS:

        case BlockID.QUARTZ_STAIRS:

        case BlockID.ACACIA_STAIRS:

        case BlockID.DARK_OAK_STAIRS:

            data ^= flipY << 2;

            switch (data) {

            case 0:

            case 1:

            case 4:

            case 5:

                return data ^ flipX;

            case 2:

            case 3:

            case 6:

            case 7:

                return data ^ flipZ;

            }

            break;

 

        case BlockID.WOODEN_DOOR:

        case BlockID.IRON_DOOR:

            if ((data & 0x8) != 0) {

                // door top halves contain no orientation information

                break;

            }

 

            switch (data & 0x3) {

            case 0: return data + flipX + flipZ * 3;

            case 1: return data - flipX + flipZ;

            case 2: return data + flipX - flipZ;

            case 3: return data - flipX - flipZ * 3;

            }

            break;

 

        case BlockID.SIGN_POST:

            switch (direction) {

            case NORTH_SOUTH:

                return (16 - data) & 0xf;

            case WEST_EAST:

                return (8 - data) & 0xf;

            default:

            }

            break;

 

        case BlockID.LADDER:

        case BlockID.WALL_SIGN:

        case BlockID.CHEST:

        case BlockID.FURNACE:

        case BlockID.BURNING_FURNACE:

        case BlockID.ENDER_CHEST:

        case BlockID.TRAPPED_CHEST:

        case BlockID.HOPPER:

            int extra = data & 0x8;

            int withoutFlags = data & ~0x8;

            switch (withoutFlags) {

            case 2:

            case 3:

                return (data ^ flipZ) | extra;

            case 4:

            case 5:

                return (data ^ flipX) | extra;

            }

            break;

 

        case BlockID.DROPPER:

        case BlockID.DISPENSER:

            int dispPower = data & 0x8;

            switch (data & ~0x8) {

            case 2:

            case 3:

                return (data ^ flipZ) | dispPower;

            case 4:

            case 5:

                return (data ^ flipX) | dispPower;

            case 0:

            case 1:

                return (data ^ flipY) | dispPower;

            }

            break;

 

        case BlockID.PUMPKIN:

        case BlockID.JACKOLANTERN:

            if (data > 3) break;

            /* FALL-THROUGH */

 

        case BlockID.REDSTONE_REPEATER_OFF:

        case BlockID.REDSTONE_REPEATER_ON:

        case BlockID.COMPARATOR_OFF:

        case BlockID.COMPARATOR_ON:

        case BlockID.COCOA_PLANT:

        case BlockID.TRIPWIRE_HOOK:

            switch (data & 0x3) {

            case 0:

            case 2:

                return data ^ (flipZ << 1);

            case 1:

            case 3:

                return data ^ (flipX << 1);

            }

            break;

 

        case BlockID.TRAP_DOOR:

            switch (data & 0x3) {

            case 0:

            case 1:

                return data ^ flipZ;

            case 2:

            case 3:

                return data ^ flipX;

            }

            break;

 

        case BlockID.PISTON_BASE:

        case BlockID.PISTON_STICKY_BASE:

        case BlockID.PISTON_EXTENSION:

            switch (data & ~0x8) {

            case 0:

            case 1:

                return data ^ flipY;

            case 2:

            case 3:

                return data ^ flipZ;

            case 4:

            case 5:

                return data ^ flipX;

            }

            break;

 

        case BlockID.RED_MUSHROOM_CAP:

        case BlockID.BROWN_MUSHROOM_CAP:

            switch (data) {

            case 1:

            case 4:

            case 7:

                data += flipX * 2;

                break;

            case 3:

            case 6:

            case 9:

                data -= flipX * 2;

                break;

            }

            switch (data) {

            case 1:

            case 2:

            case 3:

                return data + flipZ * 6;

            case 7:

            case 8:

            case 9:

                return data - flipZ * 6;

            }

            break;

 

        case BlockID.VINE:

            final int bit1, bit2;

            switch (direction) {

            case NORTH_SOUTH:

                bit1 = 0x2;

                bit2 = 0x8;

                break;

            case WEST_EAST:

                bit1 = 0x1;

                bit2 = 0x4;

                break;

            default:

                return data;

            }

            int newData = data & ~(bit1 | bit2);

            if ((data & bit1) != 0) newData |= bit2;

            if ((data & bit2) != 0) newData |= bit1;

            return newData;

 

        case BlockID.FENCE_GATE:

            switch (data & 0x3) {

            case 0:

            case 2:

                return data ^ flipZ << 1;

            case 1:

            case 3:

                return data ^ flipX << 1;

            }

            break;

 

        case BlockID.BED:

            switch (data & 0x3) {

            case 0:

            case 2:

                return data ^ flipZ << 1;

            case 1:

            case 3:

                return data ^ flipX << 1;

            }

            break;

 

        case BlockID.HEAD:

            switch (data) {

                case 2:

                case 3:

                    return data ^ flipZ;

                case 4:

                case 5:

                    return data ^ flipX;

            }

            break;

        }

 

        return data;

    }

 

 

    /**

    * Better modulo, not just remainder.

    */

    private static int mod(int x, int y) {

        int res = x % y;

        return res < 0 ? res + y : res;

    }

 

 

 

 

}

 

 

Posted

BIG Thank you Grey Ghost

 

that's got it for now. Just vanilla, but enough for the moment.

 

--------------------------- This is how it looks says the happy modder.... !!!

 

/ExecuteFile File arrow.caleb byline rotateNorth ... now rotates most commands and datavalues.

 

The full side (North) on the stairs step up. All the arrows are from the same arrow.caleb file. Should have used netherrack stairs.

 

width=800 height=411http://www.commandrunnermod.com/2015-01-27_19.22.24.png[/img]

 

 

 

 

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



×
×
  • Create New...

Important Information

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