Search in sources :

Example 1 with IExplosiveData

use of icbm.classic.api.reg.IExplosiveData in project ICBM-Classic by BuiltBrokenModding.

the class ItemRocketLauncher method onPlayerStoppedUsing.

@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entityLiving, int timeLeft) {
    if (entityLiving instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entityLiving;
        if (this.getEnergy(stack) >= ENERGY || player.capabilities.isCreativeMode) {
            // Check the player's inventory and look for missiles.
            for (int slot = 0; slot < player.inventory.getSizeInventory(); slot++) {
                ItemStack inventoryStack = player.inventory.getStackInSlot(slot);
                if (inventoryStack != null) {
                    if (// TODO add capability
                    inventoryStack.getItem() instanceof ItemMissile) {
                        final int explosiveID = inventoryStack.getItemDamage();
                        final IExplosiveData exData = ICBMClassicHelpers.getExplosive(explosiveID, true);
                        if (exData != null) {
                            // TODO add hook to block firing some missiles from launcher
                            if (exData.getTier().ordinal() + 1 <= ConfigMain.ROCKET_LAUNCHER_TIER_FIRE_LIMIT || player.capabilities.isCreativeMode) {
                                if (!world.isRemote) {
                                    EntityMissile entityMissile = new EntityMissile(player);
                                    entityMissile.missileType = MissileFlightType.HAND_LAUNCHER;
                                    entityMissile.explosiveID = explosiveID;
                                    entityMissile.acceleration = 1;
                                    entityMissile.capabilityMissile.launchNoTarget();
                                    world.spawnEntity(entityMissile);
                                    if (player.isSneaking()) {
                                        player.startRiding(entityMissile);
                                        player.setSneaking(false);
                                    }
                                    if (!player.capabilities.isCreativeMode) {
                                        player.inventory.setInventorySlotContents(slot, ItemStack.EMPTY);
                                        player.inventoryContainer.detectAndSendChanges();
                                        this.discharge(stack, ENERGY, true);
                                    }
                                }
                                // Store last time player launched a rocket
                                clickTimePlayer.put(player.getName(), System.currentTimeMillis());
                                return;
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) IExplosiveData(icbm.classic.api.reg.IExplosiveData) EntityMissile(icbm.classic.content.entity.missile.EntityMissile)

Example 2 with IExplosiveData

use of icbm.classic.api.reg.IExplosiveData in project ICBM-Classic by BuiltBrokenModding.

the class ExBlockContentReg method lockRegistry.

@Override
public void lockRegistry() {
    if (!isLocked()) {
        super.lockRegistry();
        fuseSetSupplierMap.forEach((regName, func) -> {
            final IExplosiveData data = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(regName);
            if (data != null) {
                fuseSetSupplier.addKey(data.getRegistryID(), func);
            }
        });
        fuseTickCallbackMap.forEach((regName, func) -> {
            final IExplosiveData data = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(regName);
            if (data != null) {
                fuseTickCallback.addKey(data.getRegistryID(), func);
            }
        });
        blockActivationCallbackMap.forEach((regName, func) -> {
            final IExplosiveData data = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(regName);
            if (data != null) {
                blockActiviationCallback.addKey(data.getRegistryID(), func);
            }
        });
    } else
        throw new RuntimeException(this + ": Registry was locked twice!");
}
Also used : IExplosiveData(icbm.classic.api.reg.IExplosiveData)

Example 3 with IExplosiveData

use of icbm.classic.api.reg.IExplosiveData in project ICBM-Classic by BuiltBrokenModding.

the class ExMinecartContentReg method lockRegistry.

@Override
public void lockRegistry() {
    if (!isLocked()) {
        super.lockRegistry();
        fuseSetSupplierMap.forEach((regName, func) -> {
            final IExplosiveData data = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(regName);
            if (data != null) {
                fuseSetSupplier.addKey(data.getRegistryID(), func);
            }
        });
        fuseTickCallbackMap.forEach((regName, func) -> {
            final IExplosiveData data = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(regName);
            if (data != null) {
                fuseTickCallback.addKey(data.getRegistryID(), func);
            }
        });
    } else
        throw new RuntimeException(this + ": Registry was locked twice!");
}
Also used : IExplosiveData(icbm.classic.api.reg.IExplosiveData)

Example 4 with IExplosiveData

use of icbm.classic.api.reg.IExplosiveData in project ICBM-Classic by BuiltBrokenModding.

the class ExGrenadeContentReg method lockRegistry.

@Override
public void lockRegistry() {
    if (!isLocked()) {
        super.lockRegistry();
        fuseSetSupplierMap.forEach((regName, func) -> {
            final IExplosiveData data = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(regName);
            if (data != null) {
                fuseSetSupplier.addKey(data.getRegistryID(), func);
            }
        });
        fuseTickCallbackMap.forEach((regName, func) -> {
            final IExplosiveData data = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(regName);
            if (data != null) {
                fuseTickCallback.addKey(data.getRegistryID(), func);
            }
        });
    } else
        throw new RuntimeException(this + ": Registry was locked twice!");
}
Also used : IExplosiveData(icbm.classic.api.reg.IExplosiveData)

Example 5 with IExplosiveData

use of icbm.classic.api.reg.IExplosiveData in project ICBM-Classic by BuiltBrokenModding.

the class EntityExplosion method constructBlast.

/**
 * Constructs a blast based on the parameters and sets the blast field to that value
 */
private void constructBlast(String exId, double yOffset) {
    ResourceLocation id = new ResourceLocation(exId);
    IExplosiveData exData = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(id);
    if (exData != null) {
        // TODO convert load code to blast creation helper
        final IBlastFactory factory = exData.getBlastFactory();
        if (factory != null) {
            blast = factory.create();
            ((IBlastInit) blast).setBlastWorld(world);
            ((IBlastInit) blast).setBlastPosition(posX, posY + yOffset, posZ);
            ((IBlastInit) blast).setEntityController(this);
            ((IBlastInit) blast).setExplosiveData(exData);
            ((IBlastInit) blast).buildBlast();
            return;
        }
    }
    ICBMClassic.logger().error("EntityExplosion: Failed to locate explosive with id '" + id + "'!");
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) IExplosiveData(icbm.classic.api.reg.IExplosiveData)

Aggregations

IExplosiveData (icbm.classic.api.reg.IExplosiveData)17 ResourceLocation (net.minecraft.util.ResourceLocation)6 ItemModelMapperExplosive (icbm.classic.client.mapper.ItemModelMapperExplosive)4 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)4 EntityMissile (icbm.classic.content.entity.missile.EntityMissile)3 ItemStack (net.minecraft.item.ItemStack)3 EnumTier (icbm.classic.api.EnumTier)2 HashMap (java.util.HashMap)2 IBlockState (net.minecraft.block.state.IBlockState)2 TileEntity (net.minecraft.tileentity.TileEntity)2 ICBMConstants (icbm.classic.ICBMConstants)1 ICBMClassicAPI (icbm.classic.api.ICBMClassicAPI)1 LauncherEvent (icbm.classic.api.events.LauncherEvent)1 BlastState (icbm.classic.api.explosion.BlastState)1 ICBMExplosives (icbm.classic.api.refs.ICBMExplosives)1 BlockModelMapperExplosive (icbm.classic.client.mapper.BlockModelMapperExplosive)1 icbm.classic.client.render.entity (icbm.classic.client.render.entity)1 ConfigItems (icbm.classic.config.ConfigItems)1 TESREMPTower (icbm.classic.content.blocks.emptower.TESREMPTower)1 TileEMPTower (icbm.classic.content.blocks.emptower.TileEMPTower)1