Search in sources :

Example 1 with TypeBlockRing

use of hellfirepvp.astralsorcery.common.base.patreon.types.TypeBlockRing in project AstralSorcery by HellFirePvP.

the class ProviderBlockRing method buildEffect.

@Override
public TypeBlockRing buildEffect(UUID playerUUID, List<String> effectParameters) throws Exception {
    UUID effectUniqueId = UUID.fromString(effectParameters.get(0));
    FlareColor fc = null;
    if (!"null".equals(effectParameters.get(1))) {
        fc = FlareColor.valueOf(effectParameters.get(1));
    }
    float distance = Float.parseFloat(effectParameters.get(2));
    float rotationAngle = Float.parseFloat(effectParameters.get(3));
    int repeats = Integer.parseInt(effectParameters.get(4));
    int tickRotationSpeed = Integer.parseInt(effectParameters.get(5));
    JsonArray jo = (JsonArray) PARSER.parse(effectParameters.get(6));
    HashMap<BlockPos, BlockState> pattern = new HashMap<>();
    for (JsonElement patternElement : jo) {
        JsonObject obj = (JsonObject) patternElement;
        BlockPos pos = new BlockPos(obj.getAsJsonPrimitive("posX").getAsInt(), obj.getAsJsonPrimitive("posY").getAsInt(), obj.getAsJsonPrimitive("posZ").getAsInt());
        Block b = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(obj.getAsJsonPrimitive("block").getAsString()));
        pattern.put(pos, b.getDefaultState());
    }
    return new TypeBlockRing(effectUniqueId, fc, playerUUID, distance, rotationAngle, repeats, tickRotationSpeed, pattern);
}
Also used : HashMap(java.util.HashMap) JsonObject(com.google.gson.JsonObject) TypeBlockRing(hellfirepvp.astralsorcery.common.base.patreon.types.TypeBlockRing) JsonArray(com.google.gson.JsonArray) BlockState(net.minecraft.block.BlockState) JsonElement(com.google.gson.JsonElement) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) UUID(java.util.UUID) FlareColor(hellfirepvp.astralsorcery.common.base.patreon.FlareColor)

Aggregations

JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 FlareColor (hellfirepvp.astralsorcery.common.base.patreon.FlareColor)1 TypeBlockRing (hellfirepvp.astralsorcery.common.base.patreon.types.TypeBlockRing)1 HashMap (java.util.HashMap)1 UUID (java.util.UUID)1 Block (net.minecraft.block.Block)1 BlockState (net.minecraft.block.BlockState)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 BlockPos (net.minecraft.util.math.BlockPos)1