Search in sources :

Example 11 with IExplosiveData

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

the class ItemBlockExplosive method getDetailedInfo.

@Override
public void getDetailedInfo(ItemStack stack, @Nullable EntityPlayer player, List list) {
    final IExplosiveData data = ICBMClassicHelpers.getExplosive(stack.getItemDamage(), true);
    if (data != null) {
        final EnumTier tierdata = data.getTier();
        list.add(TextFormatting.DARK_RED + LanguageUtility.getLocal("info.misc.tier") + ": " + tierdata.getTooltipColor() + tierdata.getLocalizedName());
    }
    if (// TODO add hook for any explosive via content reg
    stack.getItemDamage() == ICBMExplosives.REDMATTER.getRegistryID()) {
        // /Shhh!!! tell no one this exists, tis a surprise
        boolean taunt = shouldTauntPlayer(player);
        if (taunt) {
            switch(tauntCount) {
                case 0:
                    list.add("Place me, you know you want to :)");
                // $FALL-THROUGH$
                case 1:
                    list.add("Mine with me, lets get some minerals!!");
                // $FALL-THROUGH$
                case 2:
                    list.add("Can you hear the noises in the dark?");
                // $FALL-THROUGH$
                case 3:
                    list.add("One does not simply use");
                    list.add("redmatter to cancel redmatter");
                // $FALL-THROUGH$
                case 4:
                    list.add("Nice base you have");
                    list.add("be a shame if something");
                    list.add("would happen to it");
                // $FALL-THROUGH$
                case 5:
                    list.add("Don't worry i've changed");
                // $FALL-THROUGH$
                case 6:
                    list.add("Lets eat a world together");
                // $FALL-THROUGH$
                case 7:
                    list.add("I'm back for you");
            }
        } else {
            normalDetailedInfo(list);
        }
        // Cycle next message
        if (player != null && System.currentTimeMillis() - lastTranslationChange > changeOverDelay) {
            lastTranslationChange = System.currentTimeMillis();
            if (taunt) {
                tauntCount = player.world.rand.nextInt(7);
            } else if (redmatterRandomTranslations > 0) {
                tauntCount = player.world.rand.nextInt(redmatterRandomTranslations);
            }
        }
    } else {
        super.getDetailedInfo(stack, player, list);
    }
}
Also used : IExplosiveData(icbm.classic.api.reg.IExplosiveData) EnumTier(icbm.classic.api.EnumTier)

Example 12 with IExplosiveData

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

the class TileLauncherBase method launchMissile.

/**
 * Launches the missile
 *
 * @param target     - The target in which the missile will land in
 * @param lockHeight - height to wait before curving the missile
 */
public boolean launchMissile(Pos target, int lockHeight) {
    // Allow canceling missile launches
    if (MinecraftForge.EVENT_BUS.post(new LauncherEvent.PreLaunch(missileLauncher, missileHolder))) {
        return false;
    }
    final ItemStack stack = getMissileStack();
    if (// TODO capability
    stack.getItem() == ItemReg.itemMissile) {
        IExplosiveData explosiveData = ICBMClassicHelpers.getExplosive(stack.getItemDamage(), true);
        if (explosiveData != null) {
            target = applyInaccuracy(target);
            if (isServer()) {
                // TODO generate entity from item using handler
                EntityMissile missile = new EntityMissile(getWorld());
                // Set data
                missile.explosiveID = explosiveData.getRegistryID();
                // TODO store our launcher instance or UUID
                missile.launcherPos = new Pos((TileEntity) this);
                // TODO store offset
                missile.setPosition(xi() + 0.5, yi() + 3, zi() + 0.5);
                // Trigger launch event
                missile.capabilityMissile.launch(target.x(), target.y(), target.z(), lockHeight);
                // Spawn entity
                ((WorldServer) getWorld()).addScheduledTask(() -> getWorld().spawnEntity(missile));
                // Grab rider
                if (// TODO add hook to disable riding some missiles
                seat != null && seat.getRidingEntity() != null) {
                    Entity entity = seat.getRidingEntity();
                    seat.getRidingEntity().startRiding(null);
                    entity.startRiding(missile);
                }
                // Remove item
                getInventory().decrStackSize(0, 1);
            }
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) Pos(icbm.classic.lib.transform.vector.Pos) BlockPos(net.minecraft.util.math.BlockPos) LauncherEvent(icbm.classic.api.events.LauncherEvent) WorldServer(net.minecraft.world.WorldServer) ItemStack(net.minecraft.item.ItemStack) IExplosiveData(icbm.classic.api.reg.IExplosiveData) EntityMissile(icbm.classic.content.entity.missile.EntityMissile)

Example 13 with IExplosiveData

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

the class BlockExplosive method getActualState.

@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
    IExplosiveData explosiveData = null;
    TileEntity tile = worldIn.getTileEntity(pos);
    if (tile instanceof TileEntityExplosive && ((TileEntityExplosive) tile).capabilityExplosive != null) {
        explosiveData = ((TileEntityExplosive) tile).capabilityExplosive.getExplosiveData();
    }
    if (explosiveData != null) {
        return state.withProperty(EX_PROP, explosiveData);
    }
    return state;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IExplosiveData(icbm.classic.api.reg.IExplosiveData)

Example 14 with IExplosiveData

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

the class ICBMClassicHelpers method getExplosive.

/**
 * Called to get explosive
 *
 * @param name - registry name of the explosive
 * @return explosive desired, or default TNT
 */
public static IExplosiveData getExplosive(ResourceLocation name, boolean returnNull) {
    final IExplosiveData data = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(name);
    if (data != null) {
        return data;
    }
    System.out.println("ICBMClassicAPI: Error - Failed to locate explosive for Name[" + name + "] this may cause unexpected logic");
    return returnNull ? null : ICBMExplosives.CONDENSED;
}
Also used : IExplosiveData(icbm.classic.api.reg.IExplosiveData)

Example 15 with IExplosiveData

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

the class ClientReg method registerGrenadeRenders.

protected static void registerGrenadeRenders() {
    for (// TODO run loop once for all 4 content types
    IExplosiveData data : // TODO run loop once for all 4 content types
    ICBMClassicAPI.EX_GRENADE_REGISTRY.getExplosives()) {
        final String resourcePath = data.getRegistryName().getNamespace() + ":grenades/" + data.getRegistryName().getPath();
        grenadeModelMap.put(data, new ModelResourceLocation(resourcePath, "inventory"));
    }
    ModelLoader.registerItemVariants(ItemReg.itemGrenade, grenadeModelMap.values().stream().map(model -> new ResourceLocation(model.getNamespace() + ":" + model.getPath())).toArray(ResourceLocation[]::new));
    ModelLoader.setCustomMeshDefinition(ItemReg.itemGrenade, new ItemModelMapperExplosive(grenadeModelMap, grenadeModelMap.get(ICBMExplosives.CONDENSED)));
}
Also used : ItemModelMapperExplosive(icbm.classic.client.mapper.ItemModelMapperExplosive) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) 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