Search in sources :

Example 6 with ParametersAreNonnullByDefault

use of javax.annotation.ParametersAreNonnullByDefault in project OpenModularTurrets by OpenModularTurretsTeam.

the class BlazingClayProjectile method onHitBlock.

@Override
@ParametersAreNonnullByDefault
public void onHitBlock(IBlockState hitBlock, BlockPos pos) {
    if (hitBlock.getBlock() instanceof BlockAbstractTurretHead) {
        return;
    }
    if (!hitBlock.getMaterial().isSolid()) {
        // Go through non solid block
        return;
    }
    if (!getEntityWorld().isRemote) {
        AxisAlignedBB axis = new AxisAlignedBB(this.posX - 5, this.posY - 5, this.posZ - 5, this.posX + 5, this.posY + 5, this.posZ + 5);
        List<EntityLivingBase> targets = getEntityWorld().getEntitiesWithinAABB(EntityLivingBase.class, axis);
        int damage = ConfigHandler.getIncendiaryTurretSettings().getDamage();
        for (Entity mob : targets) {
            if (mob instanceof EntityPlayer) {
                if (canDamagePlayer((EntityPlayer) mob)) {
                    mob.attackEntityFrom(new NormalDamageSource("bullet"), damage);
                    mob.hurtResistantTime = 0;
                    mob.setFire(5);
                    playSound();
                }
            } else {
                mob.attackEntityFrom(new NormalDamageSource("bullet"), damage);
                mob.hurtResistantTime = 0;
                mob.setFire(5);
                playSound();
            }
        }
        this.setDead();
    }
}
Also used : BlockAbstractTurretHead(omtteam.openmodularturrets.blocks.turretheads.BlockAbstractTurretHead) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) NormalDamageSource(omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Example 7 with ParametersAreNonnullByDefault

use of javax.annotation.ParametersAreNonnullByDefault in project RecurrentComplex by Ivorforce.

the class CommandGenerateStructure method execute.

@Override
@ParametersAreNonnullByDefault
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args, "mirror", "select");
    String structureID = parameters.get().first().require();
    Structure<?> structure = parameters.rc().structure().require();
    WorldServer world = parameters.mc("dimension").dimension(server, sender).require();
    AxisAlignedTransform2D transform = parameters.transform("rotation", "mirror").optional().orElse(null);
    GenerationType generationType = parameters.rc("gen").generationType(structure).require();
    BlockSurfacePos pos = parameters.surfacePos("x", "z", sender.getPosition(), false).require();
    String seed = parameters.get("seed").first().optional().orElse(null);
    boolean select = parameters.has("select");
    Placer placer = generationType.placer();
    StructureGenerator<?> generator = new StructureGenerator<>(structure).world(world).generationInfo(generationType).seed(RCStrings.seed(seed)).structureID(structureID).randomPosition(pos, placer).fromCenter(true).transform(transform);
    Optional<StructureBoundingBox> boundingBox = generator.boundingBox();
    if (!boundingBox.isPresent())
        throw ServerTranslations.commandException("commands.strucGen.noPlace");
    if (structure instanceof GenericStructure && world == sender.getEntityWorld()) {
        GenericStructure genericStructureInfo = (GenericStructure) structure;
        BlockPos lowerCoord = StructureBoundingBoxes.min(boundingBox.get());
        OperationRegistry.queueOperation(new OperationGenerateStructure(genericStructureInfo, generationType.id(), generator.transform(), lowerCoord, false).withSeed(seed).withStructureID(structureID).prepare(world), sender);
    } else {
        if (generator.generate() == null)
            throw ServerTranslations.commandException("commands.strucGen.noPlace");
    }
    if (select) {
        SelectionOwner owner = RCCommands.getSelectionOwner(sender, null, false);
        owner.setSelection(RCBlockAreas.from(boundingBox.get()));
    }
}
Also used : OperationGenerateStructure(ivorius.reccomplex.world.gen.feature.structure.OperationGenerateStructure) StructureBoundingBox(net.minecraft.world.gen.structure.StructureBoundingBox) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) AxisAlignedTransform2D(ivorius.ivtoolkit.math.AxisAlignedTransform2D) BlockSurfacePos(ivorius.ivtoolkit.blocks.BlockSurfacePos) Placer(ivorius.reccomplex.world.gen.feature.structure.Placer) WorldServer(net.minecraft.world.WorldServer) GenerationType(ivorius.reccomplex.world.gen.feature.structure.generic.generation.GenerationType) RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) BlockPos(net.minecraft.util.math.BlockPos) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Example 8 with ParametersAreNonnullByDefault

use of javax.annotation.ParametersAreNonnullByDefault in project RecurrentComplex by Ivorforce.

the class ItemInventoryGenComponentTag method getSubItems.

@Override
@ParametersAreNonnullByDefault
public void getSubItems(Item item, CreativeTabs creativeTabs, NonNullList<ItemStack> list) {
    super.getSubItems(item, creativeTabs, list);
    for (String key : GenericItemCollectionRegistry.INSTANCE.ids()) {
        ItemStack stack = new ItemStack(item);
        setComponentKey(stack, key);
        list.add(stack);
    }
}
Also used : NBTTagString(net.minecraft.nbt.NBTTagString) ItemStack(net.minecraft.item.ItemStack) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Example 9 with ParametersAreNonnullByDefault

use of javax.annotation.ParametersAreNonnullByDefault in project RecurrentComplex by Ivorforce.

the class BlockScript method getPickBlock.

@Nonnull
@Override
@ParametersAreNonnullByDefault
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
    TileEntity tileEntity = world.getTileEntity(pos);
    NBTTagCompound compound = new NBTTagCompound();
    ((TileEntityBlockScript) tileEntity).writeSyncedNBT(compound);
    ItemStack returnStack = new ItemStack(Item.getItemFromBlock(this));
    returnStack.setTagInfo("scriptInfo", compound);
    return returnStack;
}
Also used : PacketEditTileEntity(ivorius.reccomplex.network.PacketEditTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Example 10 with ParametersAreNonnullByDefault

use of javax.annotation.ParametersAreNonnullByDefault in project FlareBot by FlareBot.

the class GuildWrapperLoader method load.

@Override
@ParametersAreNonnullByDefault
public GuildWrapper load(String id) {
    long start = System.currentTimeMillis();
    ResultSet set = CassandraController.execute("SELECT data FROM " + FlareBotManager.instance().GUILD_DATA_TABLE + " WHERE guild_id = '" + id + "'");
    GuildWrapper wrapper;
    Row row = set != null ? set.one() : null;
    String json = null;
    JSONConfig data;
    try {
        if (row != null) {
            json = row.getString("data");
            if (json.isEmpty() || json.equalsIgnoreCase("null")) {
                return new GuildWrapper(id);
            }
            data = new JSONConfig(parser.parse(json).getAsJsonObject(), '.', ALLOWED_SPECIAL_CHARACTERS);
            if (data.getLong("dataVersion").isPresent() && data.getLong("dataVersion").getAsLong() == 0)
                data = firstMigration(data);
            wrapper = FlareBot.GSON.fromJson(data.getObject().toString(), GuildWrapper.class);
        } else
            return new GuildWrapper(id);
    } catch (Exception e) {
        if (json == null) {
            FlareBot.LOGGER.error(Markers.TAG_DEVELOPER, "Failed to load GuildWrapper!!\n" + "Guild ID: " + id + "\n" + "Guild JSON: " + (row != null ? row.getString("data") : "New guild data!") + "\n" + "Error: " + e.getMessage(), e);
            return null;
        }
        try {
            data = new JSONConfig(parser.parse(json).getAsJsonObject(), '.', ALLOWED_SPECIAL_CHARACTERS);
        } catch (Exception e1) {
            FlareBot.LOGGER.error(Markers.TAG_DEVELOPER, "Failed to load GuildWrapper!!\n" + "Guild ID: " + id + "\n" + "Guild JSON: " + json + "\n" + "Error: " + e.getMessage(), e);
            throw new IllegalArgumentException("Invalid JSON! '" + json + "'", e1);
        }
        if (!data.getLong("dataVersion").isPresent()) {
            try {
                data = firstMigration(data);
            } catch (Exception e1) {
                FlareBot.LOGGER.error(Markers.TAG_DEVELOPER, "Failed to load GuildWrapper!!\n" + "Guild ID: " + id + "\n" + "Guild JSON: " + json + "\n" + "Error: " + e.getMessage(), e);
                throw new IllegalArgumentException("Invalid JSON! '" + json + "'", e1);
            }
            data.set("dataVersion", 1);
        }
        long version = data.getLong("dataVersion").getAsLong();
        if (version != GuildWrapper.DATA_VERSION) {
        // Migrations
        }
        json = data.getObject().toString();
        try {
            wrapper = FlareBot.GSON.fromJson(json, GuildWrapper.class);
        } catch (Exception e1) {
            FlareBot.LOGGER.error(Markers.TAG_DEVELOPER, "Failed to load GuildWrapper!!\n" + "Guild ID: " + id + "\n" + "Guild JSON: " + json + "\n" + "Error: " + e1.getMessage(), e1);
            return null;
        }
    }
    long total = (System.currentTimeMillis() - start);
    loadTimes.add(total);
    if (total >= 200) {
        Constants.getImportantLogChannel().sendMessage(MessageUtils.getEmbed().setColor(new Color(166, 0, 255)).setTitle("Long guild load time!", null).setDescription("Guild " + id + " loaded!").addField("Time", "Millis: " + System.currentTimeMillis() + "\nTime: " + LocalDateTime.now().toString(), false).addField("Load time", total + "ms", false).build()).queue();
    }
    return wrapper;
}
Also used : Color(java.awt.Color) ResultSet(com.datastax.driver.core.ResultSet) JSONConfig(io.github.binaryoverload.JSONConfig) Row(com.datastax.driver.core.Row) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Aggregations

ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)11 ItemStack (net.minecraft.item.ItemStack)4 AxisAlignedTransform2D (ivorius.ivtoolkit.math.AxisAlignedTransform2D)2 GenerationType (ivorius.reccomplex.world.gen.feature.structure.generic.generation.GenerationType)2 ArrayList (java.util.ArrayList)2 Nonnull (javax.annotation.Nonnull)2 Entity (net.minecraft.entity.Entity)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 BlockPos (net.minecraft.util.math.BlockPos)2 WorldServer (net.minecraft.world.WorldServer)2 BlockAbstractTurretHead (omtteam.openmodularturrets.blocks.turretheads.BlockAbstractTurretHead)2 NormalDamageSource (omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource)2 ResultSet (com.datastax.driver.core.ResultSet)1 Row (com.datastax.driver.core.Row)1 TreeTraverser (com.google.common.collect.TreeTraverser)1 JSONConfig (io.github.binaryoverload.JSONConfig)1 BlockSurfacePos (ivorius.ivtoolkit.blocks.BlockSurfacePos)1 SelectionOwner (ivorius.reccomplex.capability.SelectionOwner)1