Search in sources :

Example 1 with Pos

use of com.builtbroken.mc.imp.transform.vector.Pos in project Engine by VoltzEngine-Project.

the class ModelStateJsonProcessor method process.

@Override
public IRenderState process(JsonObject renderStateObject, String stateID, String globalRenderType, String subRenderType) {
    ModelState renderState;
    //Data
    String modelID = null;
    Pos offset = null;
    Pos scale = null;
    EulerAngle rotation = null;
    //Load model ID, child objects may or may not contain this
    if (renderStateObject.has("modelID")) {
        modelID = renderStateObject.get("modelID").getAsString();
    }
    //Loads position offset
    if (renderStateObject.has("offset")) {
        offset = JsonConverterPos.fromJson(renderStateObject.get("offset"));
        if (offset == null) {
            throw new IllegalArgumentException("Unknown value type for offset " + renderStateObject.get("offset"));
        }
    }
    //Loads scale value
    if (renderStateObject.has("scale")) {
        scale = JsonConverterPos.fromJson(renderStateObject.get("scale"));
        if (scale == null) {
            throw new IllegalArgumentException("Unknown value type for scale " + renderStateObject.get("scale"));
        }
    }
    //Loads rotations
    if (renderStateObject.has("rotation")) {
        JsonObject rotationObject = renderStateObject.get("rotation").getAsJsonObject();
        double yaw = 0;
        double pitch = 0;
        double roll = 0;
        if (rotationObject.has("yaw")) {
            yaw = rotationObject.getAsJsonPrimitive("yaw").getAsDouble();
        }
        if (rotationObject.has("pitch")) {
            pitch = rotationObject.getAsJsonPrimitive("pitch").getAsDouble();
        }
        if (rotationObject.has("roll")) {
            roll = rotationObject.getAsJsonPrimitive("roll").getAsDouble();
        }
        rotation = new EulerAngle(yaw, pitch, roll);
    }
    //Creates state object
    if (globalRenderType.equalsIgnoreCase("tile")) {
        renderState = new TileState(stateID, modelID, offset, scale, rotation);
    } else {
        renderState = new ModelState(stateID, modelID, offset, scale, rotation);
    }
    if (renderStateObject.has("renderOnlyParts")) {
        renderState.renderOnlyParts = renderStateObject.get("renderOnlyParts").getAsBoolean();
    }
    if (renderStateObject.has("renderParent")) {
        renderState.renderParent = renderStateObject.get("renderParent").getAsBoolean();
    }
    //Loads parts to render if all is not selected
    if (renderStateObject.has("parts")) {
        String parts = renderStateObject.get("parts").getAsString();
        if (!parts.equals("all")) {
            renderState.parts = parts.split(",");
        }
    }
    return renderState;
}
Also used : TileState(com.builtbroken.mc.client.json.render.tile.TileState) JsonConverterPos(com.builtbroken.mc.lib.json.conversion.JsonConverterPos) Pos(com.builtbroken.mc.imp.transform.vector.Pos) ModelState(com.builtbroken.mc.client.json.render.state.ModelState) JsonObject(com.google.gson.JsonObject) EulerAngle(com.builtbroken.mc.imp.transform.rotation.EulerAngle)

Example 2 with Pos

use of com.builtbroken.mc.imp.transform.vector.Pos in project Engine by VoltzEngine-Project.

the class VEProviderSmokeStream method displayEffect.

@Override
@SideOnly(Side.CLIENT)
public void displayEffect(World world, double x, double y, double z, double mx, double my, double mz, boolean movementIsEndpoint, NBTTagCompound otherData) {
    Color color = Color.gray;
    int lifeTicks = 2;
    if (otherData != null) {
        //load life timer for particle
        if (otherData.hasKey("lifeTime")) {
            lifeTicks = otherData.getInteger("lifeTime");
        }
        //Load color
        if (otherData.hasKey("red")) {
            color = new Color(otherData.getInteger("red"), otherData.getInteger("green"), otherData.getInteger("blue"));
        } else if (otherData.hasKey("color")) {
            color = new Color(otherData.getInteger("color"));
        }
    }
    FxBeam laser = new FxBeam(SharedAssets.NOISE_TEXTURE, world, new Pos(x, y, z), new Pos(mx, my, mz), color, lifeTicks);
    FMLClientHandler.instance().getClient().effectRenderer.addEffect(laser);
}
Also used : Pos(com.builtbroken.mc.imp.transform.vector.Pos) FxBeam(com.builtbroken.mc.lib.render.fx.FxBeam) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 3 with Pos

use of com.builtbroken.mc.imp.transform.vector.Pos in project Engine by VoltzEngine-Project.

the class EffectLayer method trigger.

public void trigger(World world, double x, double y, double z, double mx, double my, double mz, boolean endPoint, NBTTagCompound nbt) {
    VisualEffectProvider provider = VisualEffectRegistry.main.get(effectKey);
    if (provider != null) {
        NBTTagCompound usedNBT;
        if (nbt != null && !nbt.hasNoTags()) {
            usedNBT = (NBTTagCompound) nbt.copy();
            //Merges base NBT with server nbt
            if (this.getNbt() != null) {
                for (Object o : getNbt().func_150296_c()) {
                    if (o instanceof String) {
                        String key = (String) o;
                        NBTBase tag = getNbt().getTag(key);
                        if (tag != null) {
                            usedNBT.setTag(key, tag);
                        }
                    }
                }
            }
        } else if (this.getNbt() != null) {
            usedNBT = nbt;
        } else {
            usedNBT = new NBTTagCompound();
        }
        Pos renderOffset = this.renderOffset;
        if (renderOffset != Pos.zero && (usedNBT.hasKey("yaw") || usedNBT.hasKey("pitch"))) {
            float yaw = usedNBT.getFloat("yaw");
            float pitch = usedNBT.getFloat("pitch");
            angle.set(yaw, pitch, 0);
            renderOffset = (Pos) angle.transform(renderOffset);
        }
        provider.displayEffect(world, x + renderOffset.x(), y + renderOffset.y(), z + renderOffset.z(), mx, my, mz, endPoint, usedNBT);
    } else {
        Engine.logger().error("Failed to find a visual effect provider for key '" + effectKey + "'");
    }
}
Also used : VisualEffectProvider(com.builtbroken.mc.client.effects.VisualEffectProvider) NBTBase(net.minecraft.nbt.NBTBase) Pos(com.builtbroken.mc.imp.transform.vector.Pos) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 4 with Pos

use of com.builtbroken.mc.imp.transform.vector.Pos in project Engine by VoltzEngine-Project.

the class JsonConverterCube method fromJsonObject.

public static Cube fromJsonObject(JsonObject object) {
    JsonProcessor.ensureValuesExist(object, "min", "max");
    Pos min = JsonConverterPos.fromJson(object.get("min"));
    Pos max = JsonConverterPos.fromJson(object.get("max"));
    return new Cube(min, max);
}
Also used : Pos(com.builtbroken.mc.imp.transform.vector.Pos) Cube(com.builtbroken.mc.imp.transform.region.Cube)

Example 5 with Pos

use of com.builtbroken.mc.imp.transform.vector.Pos in project Engine by VoltzEngine-Project.

the class JsonConverterPos method fromJsonArray.

/**
     * Creates a pos from a json array containing x, y, z fields
     *
     * @param offsetObject
     * @return
     */
public static Pos fromJsonArray(JsonArray offsetObject) {
    double x = 0, y = 0, z = 0;
    JsonElement one = offsetObject.get(0);
    if (one.isJsonPrimitive()) {
        JsonPrimitive p = one.getAsJsonPrimitive();
        if (p.isNumber()) {
            x = one.getAsDouble();
        } else if (p.isString()) {
            //TODO parse
            throw new IllegalStateException("Loading json array using strings is not supported yet for pos conversion. Data: " + offsetObject);
        }
    }
    JsonElement two = offsetObject.get(1);
    if (two.isJsonPrimitive()) {
        JsonPrimitive p = two.getAsJsonPrimitive();
        if (p.isNumber()) {
            y = two.getAsDouble();
        } else if (p.isString()) {
            //TODO parse
            throw new IllegalStateException("Loading json array using strings is not supported yet for pos conversion. Data: " + offsetObject);
        }
    }
    JsonElement there = offsetObject.get(2);
    if (there.isJsonPrimitive()) {
        JsonPrimitive p = there.getAsJsonPrimitive();
        if (p.isNumber()) {
            x = there.getAsDouble();
        } else if (p.isString()) {
            //TODO parse
            throw new IllegalStateException("Loading json array using strings is not supported yet for pos conversion. Data: " + offsetObject);
        }
    }
    return new Pos(x, y, z);
}
Also used : JsonPrimitive(com.google.gson.JsonPrimitive) Pos(com.builtbroken.mc.imp.transform.vector.Pos) JsonElement(com.google.gson.JsonElement)

Aggregations

Pos (com.builtbroken.mc.imp.transform.vector.Pos)105 Block (net.minecraft.block.Block)25 TileEntity (net.minecraft.tileentity.TileEntity)13 Location (com.builtbroken.mc.imp.transform.vector.Location)11 Entity (net.minecraft.entity.Entity)11 Cube (com.builtbroken.mc.imp.transform.region.Cube)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)7 Test (org.junit.Test)7 FakeWorld (com.builtbroken.mc.testing.junit.world.FakeWorld)6 EntityMissile (icbm.classic.content.entity.EntityMissile)6 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)6 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)6 IPos3D (com.builtbroken.jlib.data.vector.IPos3D)5 PacketTile (com.builtbroken.mc.core.network.packet.PacketTile)5 EntityFlyingBlock (icbm.classic.content.entity.EntityFlyingBlock)5 ItemStack (net.minecraft.item.ItemStack)5 EulerAngle (com.builtbroken.mc.imp.transform.rotation.EulerAngle)4 BlockTile (com.builtbroken.mc.prefab.tile.BlockTile)4 Tile (com.builtbroken.mc.prefab.tile.Tile)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4