Search in sources :

Example 1 with GeneratableMapInfo

use of team.cqr.cqrepoured.world.structure.generation.generation.generatable.GeneratableMapInfo in project ChocolateQuestRepoured by TeamChocoQuest.

the class PreparableMapInfo method prepare.

@Override
protected GeneratablePosInfo prepare(World world, DungeonPlacement placement, BlockPos pos) {
    Direction transformedFacing = placement.getRotation().rotate(placement.getMirror().mirror(this.facing));
    ItemFrameEntity entity = new ItemFrameEntity(world, pos.toImmutable(), transformedFacing);
    switch(this.orientation) {
        case EAST:
            entity.setItemRotation(entity.getRotation() + 3);
            break;
        case SOUTH:
            entity.setItemRotation(entity.getRotation() + 2);
            break;
        case WEST:
            entity.setItemRotation(entity.getRotation() + 1);
            break;
        default:
            break;
    }
    int x1 = this.offsetX * (128 << this.scale);
    int z1 = this.offsetZ * (128 << this.scale);
    int x2 = this.originX;
    int z2 = this.originZ;
    switch(placement.getMirror()) {
        case LEFT_RIGHT:
            if (!this.lockOrientation) {
                if (this.orientation.getAxis() == Axis.Z) {
                    entity.setItemRotation(entity.getRotation() + 2);
                }
                z1 = -z1;
            } else {
                if (this.orientation.getAxis() == Axis.X) {
                    z1 = -z1;
                }
                if (this.orientation.getAxis() == Axis.Z) {
                    x1 = -x1;
                }
            }
            z2 = -z2;
            break;
        case FRONT_BACK:
            if (!this.lockOrientation) {
                if (this.orientation.getAxis() == Axis.X) {
                    entity.setItemRotation(entity.getRotation() + 2);
                }
                x1 = -x1;
            } else {
                if (this.orientation.getAxis() == Axis.X) {
                    z1 = -z1;
                }
                if (this.orientation.getAxis() == Axis.Z) {
                    x1 = -x1;
                }
            }
            x2 = -x2;
            break;
        default:
            break;
    }
    int x3 = x1;
    int z3 = z1;
    int x4 = x2;
    int z4 = z2;
    switch(placement.getRotation()) {
        case COUNTERCLOCKWISE_90:
            if (!this.lockOrientation) {
                entity.setItemRotation(entity.getRotation() + 1);
                x1 = z3;
                z1 = -x3;
            }
            x2 = z4;
            z2 = -x4;
            break;
        case CLOCKWISE_90:
            if (!this.lockOrientation) {
                entity.setItemRotation(entity.getRotation() + 3);
                x1 = -z3;
                z1 = x3;
            }
            x2 = -z4;
            z2 = x4;
            break;
        case CLOCKWISE_180:
            if (!this.lockOrientation) {
                entity.setItemRotation(entity.getRotation() + 2);
                x1 = -x3;
                z1 = -z3;
            }
            x2 = -x4;
            z2 = -z4;
            break;
        default:
            break;
    }
    return new GeneratableMapInfo(pos, entity, pos.getX() + x2, pos.getZ() + z2, pos.getX() + x1 + x2, pos.getZ() + z1 + z2, this.scale, this.fillMap, this.fillRadius);
}
Also used : ItemFrameEntity(net.minecraft.entity.item.ItemFrameEntity) Direction(net.minecraft.util.Direction) GeneratableMapInfo(team.cqr.cqrepoured.world.structure.generation.generation.generatable.GeneratableMapInfo)

Aggregations

ItemFrameEntity (net.minecraft.entity.item.ItemFrameEntity)1 Direction (net.minecraft.util.Direction)1 GeneratableMapInfo (team.cqr.cqrepoured.world.structure.generation.generation.generatable.GeneratableMapInfo)1